正文
增加 6 行删除 6 行
9 行未改动1011121314151617188 行未改动27282930313233343536373839409 行未改动#include<bits/stdc++.h>#define int long long//不开long long见祖宗using namespace std;const int N = 1000000000;int qpow(int a,int b){//快速幂int ans=1;while(b>0){if(b%2==1) ans=ans*a%N;b/=2;8 行未改动cin>>T;while(T--){int n;cin>>n;if(n == 1) cout<<1;//特判else if(n == 2) cout<<2;else if(n % 3 == 0) cout<<qpow(3,n/3);//n%3==0,直接输出3^(n/3)else if(n % 3 == 1) cout<<qpow(3,n/3-1)*2%N*2%N;//n%3==1,输出3^(n/3-1)*2*2else if(n % 3 == 2) cout<<qpow(3,n/3)*2%N;//n%3==2,输出3^(n/3)*2cout<<'\n';}return 0;}```9 行未改动1011121314151617188 行未改动27282930313233343536373839409 行未改动#include<bits/stdc++.h>#define int long long//不开long long见祖宗using namespace std;const int N = 1000000000;int qpow(int a,int b){//快速幂int ans=1;while(b>0){if(b%2==1) ans=ans*a%N;b/=2;8 行未改动cin>>T;while(T--){int n;cin>>n;if(n == 1) cout<<1;//特判else if(n == 2) cout<<2;else if(n % 3 == 0) cout<<qpow(3,n/3);//n%3==0,直接输出3^(n/3)else if(n % 3 == 1) cout<<qpow(3,n/3-1)*2%N*2%N;//n%3==1,输出3^(n/3-1)*2*2else if(n % 3 == 2) cout<<qpow(3,n/3)*2%N;//n%3==2,输出3^(n/3)*2cout<<'\n';}return 0;}```