結果
問題 | No.747 循環小数N桁目 Hard |
ユーザー | wakannyaai |
提出日時 | 2020-03-10 21:07:32 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 22 ms / 2,000 ms |
コード長 | 6,051 bytes |
コンパイル時間 | 1,645 ms |
コンパイル使用メモリ | 184,796 KB |
実行使用メモリ | 35,688 KB |
最終ジャッジ日時 | 2024-04-27 18:52:56 |
合計ジャッジ時間 | 6,676 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 12 ms
35,328 KB |
testcase_01 | AC | 12 ms
35,408 KB |
testcase_02 | AC | 11 ms
35,328 KB |
testcase_03 | AC | 11 ms
35,328 KB |
testcase_04 | AC | 12 ms
35,244 KB |
testcase_05 | AC | 13 ms
35,304 KB |
testcase_06 | AC | 13 ms
35,328 KB |
testcase_07 | AC | 12 ms
35,308 KB |
testcase_08 | AC | 12 ms
35,328 KB |
testcase_09 | AC | 13 ms
35,252 KB |
testcase_10 | AC | 12 ms
35,356 KB |
testcase_11 | AC | 12 ms
35,392 KB |
testcase_12 | AC | 13 ms
35,328 KB |
testcase_13 | AC | 12 ms
35,328 KB |
testcase_14 | AC | 12 ms
35,428 KB |
testcase_15 | AC | 12 ms
35,244 KB |
testcase_16 | AC | 12 ms
35,444 KB |
testcase_17 | AC | 12 ms
35,200 KB |
testcase_18 | AC | 12 ms
35,456 KB |
testcase_19 | AC | 12 ms
35,328 KB |
testcase_20 | AC | 12 ms
35,328 KB |
testcase_21 | AC | 12 ms
35,448 KB |
testcase_22 | AC | 14 ms
35,328 KB |
testcase_23 | AC | 12 ms
35,328 KB |
testcase_24 | AC | 12 ms
35,200 KB |
testcase_25 | AC | 12 ms
35,368 KB |
testcase_26 | AC | 12 ms
35,204 KB |
testcase_27 | AC | 12 ms
35,424 KB |
testcase_28 | AC | 12 ms
35,368 KB |
testcase_29 | AC | 11 ms
35,204 KB |
testcase_30 | AC | 12 ms
35,244 KB |
testcase_31 | AC | 12 ms
35,328 KB |
testcase_32 | AC | 15 ms
35,328 KB |
testcase_33 | AC | 13 ms
35,440 KB |
testcase_34 | AC | 13 ms
35,456 KB |
testcase_35 | AC | 13 ms
35,456 KB |
testcase_36 | AC | 14 ms
35,456 KB |
testcase_37 | AC | 13 ms
35,308 KB |
testcase_38 | AC | 13 ms
35,308 KB |
testcase_39 | AC | 13 ms
35,328 KB |
testcase_40 | AC | 13 ms
35,476 KB |
testcase_41 | AC | 13 ms
35,536 KB |
testcase_42 | AC | 15 ms
35,328 KB |
testcase_43 | AC | 13 ms
35,328 KB |
testcase_44 | AC | 14 ms
35,328 KB |
testcase_45 | AC | 13 ms
35,328 KB |
testcase_46 | AC | 14 ms
35,328 KB |
testcase_47 | AC | 14 ms
35,580 KB |
testcase_48 | AC | 14 ms
35,376 KB |
testcase_49 | AC | 14 ms
35,384 KB |
testcase_50 | AC | 12 ms
35,456 KB |
testcase_51 | AC | 13 ms
35,456 KB |
testcase_52 | AC | 12 ms
35,328 KB |
testcase_53 | AC | 16 ms
35,688 KB |
testcase_54 | AC | 14 ms
35,584 KB |
testcase_55 | AC | 14 ms
35,652 KB |
testcase_56 | AC | 14 ms
35,556 KB |
testcase_57 | AC | 13 ms
35,412 KB |
testcase_58 | AC | 16 ms
35,584 KB |
testcase_59 | AC | 14 ms
35,464 KB |
testcase_60 | AC | 13 ms
35,456 KB |
testcase_61 | AC | 15 ms
35,456 KB |
testcase_62 | AC | 15 ms
35,456 KB |
testcase_63 | AC | 15 ms
35,456 KB |
testcase_64 | AC | 14 ms
35,328 KB |
testcase_65 | AC | 12 ms
35,328 KB |
testcase_66 | AC | 15 ms
35,320 KB |
testcase_67 | AC | 13 ms
35,404 KB |
testcase_68 | AC | 14 ms
35,472 KB |
testcase_69 | AC | 14 ms
35,328 KB |
testcase_70 | AC | 12 ms
35,480 KB |
testcase_71 | AC | 12 ms
35,328 KB |
testcase_72 | AC | 13 ms
35,328 KB |
testcase_73 | AC | 13 ms
35,536 KB |
testcase_74 | AC | 14 ms
35,456 KB |
testcase_75 | AC | 14 ms
35,456 KB |
testcase_76 | AC | 14 ms
35,312 KB |
testcase_77 | AC | 19 ms
35,328 KB |
testcase_78 | AC | 19 ms
35,580 KB |
testcase_79 | AC | 20 ms
35,456 KB |
testcase_80 | AC | 21 ms
35,456 KB |
testcase_81 | AC | 19 ms
35,376 KB |
testcase_82 | AC | 18 ms
35,456 KB |
testcase_83 | AC | 18 ms
35,328 KB |
testcase_84 | AC | 20 ms
35,456 KB |
testcase_85 | AC | 20 ms
35,456 KB |
testcase_86 | AC | 19 ms
35,456 KB |
testcase_87 | AC | 20 ms
35,456 KB |
testcase_88 | AC | 18 ms
35,424 KB |
testcase_89 | AC | 19 ms
35,376 KB |
testcase_90 | AC | 18 ms
35,328 KB |
testcase_91 | AC | 19 ms
35,444 KB |
testcase_92 | AC | 20 ms
35,328 KB |
testcase_93 | AC | 19 ms
35,328 KB |
testcase_94 | AC | 20 ms
35,440 KB |
testcase_95 | AC | 19 ms
35,580 KB |
testcase_96 | AC | 20 ms
35,456 KB |
testcase_97 | AC | 20 ms
35,584 KB |
testcase_98 | AC | 22 ms
35,620 KB |
testcase_99 | AC | 20 ms
35,540 KB |
testcase_100 | AC | 20 ms
35,496 KB |
testcase_101 | AC | 19 ms
35,584 KB |
testcase_102 | AC | 18 ms
35,456 KB |
testcase_103 | AC | 21 ms
35,456 KB |
testcase_104 | AC | 16 ms
35,384 KB |
testcase_105 | AC | 14 ms
35,436 KB |
testcase_106 | AC | 15 ms
35,584 KB |
testcase_107 | AC | 13 ms
35,516 KB |
testcase_108 | AC | 15 ms
35,456 KB |
testcase_109 | AC | 15 ms
35,436 KB |
testcase_110 | AC | 14 ms
35,400 KB |
testcase_111 | AC | 15 ms
35,376 KB |
testcase_112 | AC | 14 ms
35,456 KB |
testcase_113 | AC | 15 ms
35,516 KB |
testcase_114 | AC | 14 ms
35,584 KB |
testcase_115 | AC | 14 ms
35,456 KB |
testcase_116 | AC | 15 ms
35,456 KB |
testcase_117 | AC | 14 ms
35,496 KB |
testcase_118 | AC | 15 ms
35,400 KB |
testcase_119 | AC | 14 ms
35,584 KB |
testcase_120 | AC | 14 ms
35,440 KB |
testcase_121 | AC | 14 ms
35,456 KB |
testcase_122 | AC | 14 ms
35,396 KB |
testcase_123 | AC | 14 ms
35,436 KB |
ソースコード
#include "bits/stdc++.h" #include <random> #include <algorithm> #include <unordered_set> #define rep(i,n) for(int i = 0; i < n; i++) typedef long long ll; typedef unsigned long long ull; using namespace std; #define vll vector<vector<long long>> #define vl vector<long long> #define vi vector<int> #define vii vector<vector<int>> #define pb push_back #define pf push_front #define ld long double #define Sort(a) sort(a.begin(),a.end()) #define cSort(a,cmp) sort(a.begin(),a.end(),cmp) #define reSort(a) sort(a.rbegin(), a.rend()) static const ll llMAX = numeric_limits<long long>::max(); static const int intMAX = numeric_limits<int>::max(); static const ll llMIN = numeric_limits<long long>::min(); static const int intMIN = numeric_limits<int>::min(); static const ll d_5 = 100000; static const ll d9_7 = 1000000007; static const ll d_9 = 1000000000; static const double PI=3.14159265358979323846; template<class T> void Printvector(std::vector<T> a){ int size = a.size(); rep(i,size){ cout<<a[i]<<" "; } cout<<endl; } template<class T> void Printvector(std::vector<std::vector<T>> a){ int size = a.size(); rep(i,size){ int size2=a[i].size(); rep(j,size2){ cout<<a[i][j]<<" "; } cout<<endl; } cout<<endl; } template<class T> vector<T> getaccum(vector<T> a){ int size=a.size(); vector<T> ans(size); ans[0]=a[0]; for(int i=0;i<size-1;i++){ ans[i+1]=ans[i]+a[i+1]; //ans[i+1]%=d9_7; } return ans; } template<class T> vector<vector<T>> getaccum2D(vector<vector<T>> a){ int sizey=a.size(); int sizex=a[0].size(); vector<vector<T>> ans(sizey,vector<T>(sizex,0)); //ans=a; ans[0][0]=a[0][0]; for(int i=1;i<sizex;i++){ ans[0][i]=ans[0][i-1]+a[0][i]; } for(int i=1;i<sizex;i++){ ans[i][0]=ans[i-1][0]+a[i][0]; } for (int i = 0; i < sizey-1; i++) for (int j = 0; j < sizex-1; j++) ans[i+1][j+1] = ans[i][j+1] + ans[i+1][j] - ans[i][j] + a[i+1][j+1]; return ans; } ll getaccumnum(vector<ll> accum,int l,int r){//閉区間[l,r]の総和 if(l==0){ return accum[r]; }else{ return accum[r]-accum[l-1]; } } template<class T> T getaccumnum2D(vector<vector<T>>& accum,int x1,int y1,int x2,int y2){//2の方が右下、閉区間 T ans=accum[y2][x2]; if(x1==0 && y1==0){ ; }else if(x1>0 && y1==0){ ans-=accum[y2][x1-1]; }else if(x1==0 && y1>0){ ans-=accum[y1-1][x2]; }else{ ans-=accum[y1-1][x2]; ans-=accum[y2][x1-1]; ans+=accum[y1-1][x1-1]; } return ans; } ll digitpower(ll a,ll b){//aのb乗を計算 if(b==1){ return a; }else if(b==0){ return 1; } int mode=0; if(b%2==1){ ll tmp = digitpower(a,(b-1)/2); if(mode==1){ tmp%=d9_7; } tmp*=tmp; if(mode==1){ tmp%=d9_7; } tmp*=a; if(mode==1){ return tmp%d9_7; }else{ return tmp; } }else{ ll tmp = digitpower(a,(b)/2); if(mode==1){ tmp%=d9_7; } tmp*=tmp; if(mode==1){ tmp%=d9_7; } if(mode==1){ return tmp%d9_7; }else{ return tmp; } } } vl facs(2000010,-1); ll Factrial(ll num){ if(facs[num]!=-1){ return facs[num]; } if(num==1||num<=0){ return 1; }else if(num<0){ printf("ERROR_minus\n"); return 0; }else{ facs[num]=(num*Factrial(num-1))%d9_7; return facs[num]; } } long long modinv(long long a, long long m) {//modの逆元 long long b = m, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u; } vl invs(2000010,-1); ll linercomb(ll n,ll k, ll mod){//n,kの線形時間で求める if(n<k)return 0; if(n<0)return 0; if(k==0 || k==n)return 1; ll ans=Factrial(n); if(invs[k]==-1){ invs[k]=modinv(Factrial(k),mod); } ans*=invs[k]; ans%=d9_7; ll k1=Factrial(n-k); k1%=mod; ans*=modinv(k1,mod); ans%=mod; return ans; } unordered_map<ll,ll> prime_factor(int64_t n) { unordered_map<ll,ll> ret; for(int64_t i = 2; i * i <= n; i++) { while(n % i == 0) { ret[i]++; n /= i; } } if(n != 1) ret[n] = 1; return ret; } struct datas{ ll p; ll q; };/* bool cmp(const datas &a, const datas &b) { return a.num < b.num; }*/ template<class T> T gcd(T a,T b){ if(a==0){ return b; }else if(b==0){ return a; } while(1) { if(a < b) swap(a, b); if(!b) break; a %= b; } return a; } int LCS(string s,string t) { int n=s.size(); int m=t.size(); vector<vector<int>> dp=vector<vector<int>>(n+1,vector<int>(m+1,0)); for (int i=0; i<n; ++i) { for (int j=0; j<m; ++j) { if (s[i] == t[j]) { dp[i+1][j+1] = dp[i][j] + 1; } else { dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]); } } } return dp[n][m]; } //素数列挙 #define P 100000 vl primes; vl primenum(P+1); vector<bool> bprime(P+200); ll searchprime(ll max){//発見した素因数の個数を返す //max+=180; bprime[1]=false; // cout<<"rrr"<<endl;; //cout<<max<<" "<<bprime.size()<<endl; for(ll i=2;i<=max;i++){ bprime[i]=true; } //// cout<<"r"; ll nowprimes=1; primes.pb(2); for(ll i=4;i<max;i+=2){ bprime[i]=false; } // cout<<"e"; for(ll i=3;i<=max;i+=2){ if(bprime[i]==true){ //primes[nowprimes]=i; primes.pb(i); nowprimes++; for(ll j=2;i*j<=max;j++){ bprime[i*j]=false; } } } return nowprimes; } int main(void){ string n,k; cin>>n>>k; vector<int> ntos={2,8,5,7,1,4}; int nsize=n.size(); int ksize=k.size(); int ans=0; rep(i,nsize){ ans+=n[i]-'0'; ans%=6; ans*=10; } ans/=10; int tmpk=k[ksize-1]%2; if(tmpk==0){ tmpk=2; } ll ans2=digitpower((ll)ans,(ll)tmpk); ans2%=6; ans2+=5; ans2%=6; cout<<ntos[ans2]<<endl; return 0; } //<<std::setprecision(30) //重複削除 /* std::sort(vec.begin(), vec.end()); vec.erase(std::unique(vec.begin(), vec.end()), vec.end());*/