Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define read() freopen("C:\\Users\\HP NPC\\Documents\\cf\\code\\input.txt","r",stdin)
- #define write() freopen("C:\\Users\\HP NPC\\Documents\\cf\\code\\output.txt","w",stdout)
- using namespace std;
- int main()
- {
- read();
- write();
- int tc;
- cin>>tc;
- for(int t=1;t<=tc;t++)
- {
- printf("Case %d: ",t);
- string a, b;
- cin>>a>>b;
- int len_a = a.size();
- int len_b=b.size();
- long long sum_a=0;
- for(int i =0;i<len_a;i++)
- {
- sum_a=1+ ((sum_a*10)%9+ (a[i]-'1')%9)%9;
- }
- //cout<<sum_a<<endl;
- long long sum_b=0;
- for(int i =0;i<len_b;i++)
- {
- sum_b = 1+((((sum_b*10)%6)+(b[i]-'1')%6)%6);
- }
- //cout<<sum_b<<endl;
- long long res = 1+(((int)pow(sum_a,sum_b)-1)%9);
- cout<<res<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment