-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPMD7.cpp
More file actions
54 lines (50 loc) · 829 Bytes
/
PMD7.cpp
File metadata and controls
54 lines (50 loc) · 829 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>
using namespace std;
#define ll long long
ll power(ll base,ll n)
{
ll ans=1;
while(n)
{
if(n&1)
{
n=n-1;
ans=ans*base;
}else
{
n/=2;
base=base*base;
}
}
return ans;
}
int main() {
int t;
cin>>t;
while(t--)
{
ll int x,m,y,last;
cin>>x>>m;
ll int finalans=0;
while(x)
{
last = x % 10;
y = m % 4;
if (y == 0 && m != 0)
{
y = 4;
}
ll int ans=power(x%10,y);
x=x/10;
finalans+=ans%10;
if(x)
finalans*=10;
}
if(finalans%7==0)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
//cout<<finalans<<endl;
}
return 0;
}