結果
| 問題 |
No.152 貯金箱の消失
|
| コンテスト | |
| ユーザー |
okchan08
|
| 提出日時 | 2018-04-06 22:16:08 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 194 ms / 5,000 ms |
| コード長 | 598 bytes |
| コンパイル時間 | 559 ms |
| コンパイル使用メモリ | 58,400 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-26 10:51:06 |
| 合計ジャッジ時間 | 3,636 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 12 |
ソースコード
#include <iostream>
#include <vector>
using namespace std;
using ll = unsigned long long;
const int MOD = 1e6+3;
const int MAX = 1e7;
ll gcd(ll a, ll b){
if(b==0) return a;
return gcd(b, a%b);
}
int main(){
int L; cin >> L;
int ans = 0;
for(int i=1;i*i<=MAX; i++){
for(int j=1; j<i && i*i + j*j < MAX;j++){
if(i%2 == j%2) continue;
if(gcd(i,j) > 1) continue;
ll a = i*i - j*j;
ll b = 2*i*j;
ll c = i*i + j*j;
if((a+b+c)*4 <= L) (ans += 1) %= MOD;
}
}
cout << ans << endl;
}
okchan08