結果
| 問題 | No.3577 フェルマー曲線 |
| コンテスト | |
| ユーザー |
tau1235
|
| 提出日時 | 2026-07-03 21:26:54 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 305 ms / 4,000 ms |
| コード長 | 464 bytes |
| 記録 | |
| コンパイル時間 | 2,181 ms |
| コンパイル使用メモリ | 332,212 KB |
| 実行使用メモリ | 6,528 KB |
| 最終ジャッジ日時 | 2026-07-03 21:27:03 |
| 合計ジャッジ時間 | 5,989 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 24 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll modpow(ll n,ll k,ll mod){
ll pw=n;
ll ret=1;
while (k){
if (k%2==1){
ret*=pw;
ret%=mod;
}
pw=pw*pw;
pw%=mod;
k/=2;
}
return ret;
}
int main(){
ll n,b;
cin>>n>>b;
vector<ll> pw(b),cnt(b);
for (int i=0;i<b;i++) cnt[pw[i]=modpow(i,n,b)]++;
ll ans=0;
for (int i=0;i<b;i++) for (int j=0;j<b;j++) ans+=cnt[(pw[i]+pw[j])%b];
cout<<ans<<endl;
}
tau1235