結果
| 問題 | 
                            No.747 循環小数N桁目 Hard
                             | 
                    
| コンテスト | |
| ユーザー | 
                             peroon
                         | 
                    
| 提出日時 | 2019-06-25 00:36:53 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 1,524 bytes | 
| コンパイル時間 | 1,338 ms | 
| コンパイル使用メモリ | 168,904 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-06-22 18:31:41 | 
| 合計ジャッジ時間 | 3,920 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 120 | 
コンパイルメッセージ
main.cpp: In function 'll mod6(ll, ll)':
main.cpp:51:1: warning: control reaches end of non-void function [-Wreturn-type]
   51 | }
      | ^
            
            ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
const ll mod = 1e9 + 7;
const ll inf = 1e18;
ll ll_pow(ll a, ll n){
    ll ans = 1;
    FOR(i, 0, n){
        ans *= a;
    }
    return ans;
}
ll ctoi(char c ){
    ll v = c - '0';
    return v;
}
ll string_sum(string s){
    ll sum = 0;
    for(char c : s){
        sum += ctoi(c);
    }
    return sum;
}
ll mod2(string s){
    ll v = ctoi(s.back());
    return v % 2;
}
ll mod6(ll mod2, ll mod3){
    if(mod2==0 && mod3==0) return 0;
    if(mod2==1 && mod3==1) return 1;
    if(mod2==0 && mod3==2) return 2;
    if(mod2==1 && mod3==0) return 3;
    if(mod2==0 && mod3==1) return 4;
    if(mod2==1 && mod3==2) return 5;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    // input
    string N, K;
    cin >> N >> K;
    ll N_mod_3 = string_sum(N) % 3;
    ll N_mod_2 = mod2(N);
    ll N_mod_6 = mod6(N_mod_2, N_mod_3);
    ll K_mod_2 = mod2(K);
    if(K_mod_2==0) K_mod_2+=2;
    ll keta = ll_pow(N_mod_6, K_mod_2);
    keta %= 6;
    if(keta==0) keta+=6;
    string s = "285714";
    p(s[keta-1]);
    
    return 0;
}
            
            
            
        
            
peroon