結果
| 問題 | No.3577 フェルマー曲線 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-07-03 22:44:54 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 1,091 ms / 4,000 ms |
| コード長 | 618 bytes |
| 記録 | |
| コンパイル時間 | 1,401 ms |
| コンパイル使用メモリ | 219,228 KB |
| 実行使用メモリ | 6,528 KB |
| 最終ジャッジ日時 | 2026-07-03 22:45:20 |
| 合計ジャッジ時間 | 3,832 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 24 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
ll N,B;
ll f(ll x,ll n){
ll res=1;
while(n!=0LL){
if(n%2!=0LL) res=(res*x)%B;
x=(x*x)%B;
n/=2;
}
return res;
}
int main(void){
cin.tie(nullptr); ios_base::sync_with_stdio(false);
ll i,j;
cin >> N >> B;
map<ll,ll> m;
for(i=0;i<B;i++){
m[f(i,N)]++;
}
ll ans=0;
for(auto x:m){
for(auto y:m){
ll p=(x.first+y.first)%B;
if(m.count(p)!=0){
ans+=m[p]*x.second*y.second;
}
}
}
cout << ans << endl;
return 0;
}