結果
| 問題 | 
                            No.747 循環小数N桁目 Hard
                             | 
                    
| コンテスト | |
| ユーザー | 
                             🍮かんプリン
                         | 
                    
| 提出日時 | 2019-08-27 10:03:51 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 5 ms / 2,000 ms | 
| コード長 | 1,152 bytes | 
| コンパイル時間 | 1,693 ms | 
| コンパイル使用メモリ | 168,720 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-11-14 04:18:55 | 
| 合計ジャッジ時間 | 5,785 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 120 | 
ソースコード
#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = MOD - 1;
const ll LLINF = 4e18;
int main() {
    string N, K; cin >> N >> K;
    int a = 0;
    REP(i, N.size()) {
        a += N[i] - '0';
    }
    a %= 3;
    int b = (N[N.size() - 1] - '0') % 2;
    if (a == 0 && b == 0) {
        puts("4");
    }
    else if (a == 1 && b == 1) {
        puts("2");
    }
    else if (a == 2 && b == 0) {
        if ((K[K.size() - 1] - '0') % 2 == 0) {
            puts("7");
        }
        else {
            puts("8");
        }
    }
    else if (a == 0 && b == 1) {
        puts("5");
    }
    else if (a == 1 && b == 0) {
        puts("7");
    }
    else if (a == 2 && b == 1) {
        if ((K[K.size() - 1] - '0') % 2 == 0) {
            puts("2");
        }
        else {
            puts("1");
        }
    }
    getchar(); getchar();
}
            
            
            
        
            
🍮かんプリン