結果
| 問題 | 
                            No.487 2017 Calculation(2017の計算)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2025-02-25 22:23:50 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 612 bytes | 
| コンパイル時間 | 1,664 ms | 
| コンパイル使用メモリ | 159,956 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2025-02-25 22:23:53 | 
| 合計ジャッジ時間 | 2,715 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge6 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 16 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:26:11: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   26 |     scanf ("%lld", &mod);
      |     ~~~~~~^~~~~~~~~~~~~~
            
            ソースコード
# include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
# define int long long
# define lc u << 1
# define rc u << 1 | 1
# define fi first
# define se second
// const int N = 2025;
const int N = 2017;
int mod;
int quick_pow (int a, int b)
{
    int ans = 1;
    while (b)
    {
        if (b & 1) ans = ans * a % mod;
        a = a * a % mod, b >>= 1;
    }
    return ans;
}
signed main ()
{
    // freopen ("2025.in", "r", stdin); freopen ("2025.out", "w", stdout);
    scanf ("%lld", &mod);
    int ans = (N + quick_pow (N * N % mod, N) % mod) % mod;
    printf ("%lld\n", ans);
    return 0;
}