結果

問題 No.747 循環小数N桁目 Hard
ユーザー alorie10
提出日時 2018-10-20 00:50:42
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 827 bytes
コンパイル時間 700 ms
コンパイル使用メモリ 55,796 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-19 00:03:21
合計ジャッジ時間 3,938 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 120
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
typedef long long ll;
int main(void){
    // Your code here!
    int v[]={1,3,2,6,4,5};
    string ss,tt;
    cin>>ss>>tt;
    int ans;
    int p=(ss.size()-1)%6;
    int n=ss[ss.size()-1]-'0',k=tt[tt.size()-1]-'0';
    for(int i=0;i<ss.size()-1;i++){
        n+=4*(ss[i]-'0');
        //cout<<n<<v[p]<<ss[i]<<endl;
        n%=6;
        //cout<<n<<endl;
    }
    if(n==0 || n==1 || n==4 || n==3)ans=n+6*(n==0);
    else if(n==2){
        if(k%2==1)ans=2;
        else ans=4;
    }
    else{
        if(k%2==1)ans=5;
        else ans=1;
    }
    int s[]={2,8,5,7,1,4};
    cout<<s[ans-1]<<endl;
}
    
    /*cout<<n<<k<<endl;
    ll ans=1;
    for(int i=0;i<k;i++){
        ans*=n;
        ans%=6;
    }
    int s[]={2,8,5,7,1,4};
    cout<<ans-1<<endl;
    cout<<s[ans-1]<<endl;
}*/
0