QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#184974#6138. Function and Functionchitoge#AC ✓17ms3600kbC++141.7kb2023-09-21 15:14:382023-09-21 15:14:39

Judging History

你现在查看的是最新测评结果

  • [2023-09-21 15:14:39]
  • 评测
  • 测评结果:AC
  • 用时:17ms
  • 内存:3600kb
  • [2023-09-21 15:14:38]
  • 提交

answer


#pragma GCC optimize("Ofast")

//booster_^^
#include<bits/stdc++.h>

#define FC(a,b,c) for(int i=a;i<b;i++)cin>>c[i]
#define Fn(n) for(int i=0;i<n;i++)
#define fin(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define F(a,b) for(int i=a;i<b;i++)
#define all(a) a.begin(),a.end()
#define umap_boost(x) x.reserve(1024);x.max_load_factor(0.25);

#define PII pair<int,int> 
#define ll long long
#define endl '\n'
using namespace std;

inline void cin_unlocked()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
}

template <typename T>
inline void stable_unique(vector<T>& v ){
    set<T> m(v.begin(),v.end());
    v.assign(m.begin(),m.end());
}


class dsu{
public:
    int n;
    vector<int> c;

    int q(int x){
        if(c[x]!=x){
            c[x]=q(c[x]);
        }
        return c[x];
    }
    void u(int a,int b){
        int fa=q(a);
        int fb=q(b);
        if(fa!=fb)
            c[fa]=fb;
    }

    dsu(int &_n){
        this->n=_n+5;
        this->c.resize(n);
        for(int i=0;i<n;i++)c[i]=i;
    }

};

int pow_mod(int a, int b,int mod) {//a^b
    int ans = 1;
    while(b > 0) {
        if(b & 1) ans = ans * a % mod; 
        a = a * a % mod;
        b >>= 1;
    }
    return ans;
}

int f[15]={1,0,0,0,1,0,1,0,2,1};

inline void solve(){
	int a,b;
	cin>>a>>b;
	if(!b){
		cout<<a<<endl;
		return;
	}

	while(b&&a>1){
		int c=0;
		while(a){
			c+=f[a%10];
			a/=10;
		}
		a=c;
		b--;
        // cout<<">>>"<<a<<' '<<b<<endl;
	}

    if(b)
	   a=a^(b%2);
	// cout<<b<<' '<<a<<endl;
    cout<<a<<endl;
}

int main(){
	cin_unlocked();
	int t;cin>>t;for(;t--;)
	   solve();

	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3596kb

input:

6
123456789 1
888888888 1
888888888 2
888888888 999999999
98640 12345
1000000000 0

output:

5
18
2
0
0
1000000000

result:

ok 6 numbers

Test #2:

score: 0
Accepted
time: 17ms
memory: 3600kb

input:

100000
579268184 2
120252252 777743676
255650198 1
152055433 207664522
137430584 754115403
646417467 164848484
743551976 0
0 408695577
363072674 569574204
464290891 0
761830281 3
0 1
49176280 2
791182580 0
474930784 3
402374924 0
739903247 91553857
0 2
688106229 2
65907033 152261569
875191599 3
5319...

output:

0
0
5
0
1
1
743551976
1
1
464290891
0
1
1
791182580
1
402374924
0
0
2
0
1
1
2
1
0
0
0
3
0
0
0
1
0
0
1
0
2
0
1
1
1
0
1
0
0
0
0
0
0
1
55349255
486354015
1
1
0
1
1
0
1
1
0
1
0
9
0
1
1
0
0
1
0
1
1
1
0
0
0
0
25600152
0
0
1
22903397
705086250
771453912
1
1
0
0
1
0
1
1
1
2
1
1
1
1
1
1
6
3
3
1
0
1
0
1
86248...

result:

ok 100000 numbers