結果
| 問題 | 
                            No.747 循環小数N桁目 Hard
                             | 
                    
| コンテスト | |
| ユーザー | 
                             mtsd
                         | 
                    
| 提出日時 | 2018-10-19 21:33:37 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 6 ms / 2,000 ms | 
| コード長 | 1,050 bytes | 
| コンパイル時間 | 829 ms | 
| コンパイル使用メモリ | 81,388 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-11-18 20:09:24 | 
| 合計ジャッジ時間 | 4,142 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 120 | 
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)
int q[] = {2,8,5,7,1,4};
int main(){
    string s,t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    int a;
    int b;
    if((s[n-1]-'0')%2==0){
        a = 0;
    }else{
        a = 1;
    }
    int p = 0;
    for(auto x:s){
        p += x-'0';
        p %=3;
    }
    if(p==0){
        b = 0;
    }else if(p==1){
        b = 1;
    }else{
        if((t[m-1]-'0')%2==0){
            b = 1;
        }else{
            b = 2;
        }
    }
    int ans = 0;
    for(int i=1;i<=6;i++){
        if(i%2==a&&i%3==b)ans = i;
    }
    ans--;
    cout << q[ans] << endl;
    return 0;
}
            
            
            
        
            
mtsd