Submission #936814

# Submission time Handle Problem Language Result Execution time Memory
936814 2024-03-02T18:42:18 Z Habiba Trol (COCI19_trol) C++17
50 / 50
0 ms 348 KB
#include <bits/stdc++.h>
#define HABIBA  ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0);
#define PP push_back
#define LL long long
#define F first
#define S second
#define lp int Q; cin >>Q; while (Q--)
#define inp for(LL i=0; i<n;i++){cin >>a[i];}
#define sorting sort (a,a+n);
#define outp for (LL I=0; I<N;I++) {cout <<ARRAY[I]<<"\n";}
#define cout(X) for(auto V:X)cout<<V<<"\n";
#define coutp(X) for(auto V:X)cout<<V.F<<' '<<V.S<<'\n';
#define cin(X) for(auto &V:X)cin>>V;
#define pb(X) push_back(X);
#define all(X)  X.begin(),X.end()
#define OR or
#define AND and
const LL MOD = 1e9 + 7;
const LL N = 1e5 + 7;
using namespace std;
int main() {
HABIBA
lp{
unsigned long long a,b,sum=0,c=0,sum1=0;
cin >>a>>b;
if (a==b){
cout <<a<<"\n";
continue;	
}
c=(b-a);
c++;
while (a>0 || sum>9){
if (a==0) a=sum,sum=0;	
sum+=(a%10);
a/=10;
} 
while (b>0 || sum1>9){
if (b==0) b=sum1,sum1=0;	
sum1+=(b%10);
b/=10;
} 
//cout <<c<<" "<<sum<<" "<<sum1<<"\n";
unsigned long long ans=(45*(c/9));
if (sum1<=sum) sum1+=10;
//cout <<ans<<" ";
int x= c%9;
for (int i=1; i<=x;i++){
ans+=sum;
sum++; if (sum==10) sum=1;	
}
cout <<ans<<"\n";
}
return 0;
} 
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct