結果

問題 No.487 2017 Calculation(2017の計算)
ユーザー phsplsphspls
提出日時 2020-04-12 01:16:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 483 bytes
コンパイル時間 1,634 ms
コンパイル使用メモリ 167,832 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 23:39:34
合計ジャッジ時間 2,413 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define llong long long

int getval(int times, int divisor) {
    if(divisor==1) return 0;
    if(times==0) return 1;
    if(times==1) return 2017 % divisor;
    int val = getval(times/2, divisor) % divisor;
    return val * val % divisor * getval(times%2, divisor);
}

int main() {
    int m;
    cin >> m;
    int result = (2017 + getval(4034, m)) % m;
    cout << result << "\n";
}
0