結果
問題 | No.800 四平方定理 |
ユーザー | ohreitetsu |
提出日時 | 2019-04-25 22:52:00 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,075 bytes |
コンパイル時間 | 954 ms |
コンパイル使用メモリ | 77,236 KB |
実行使用メモリ | 80,432 KB |
最終ジャッジ日時 | 2023-08-13 21:52:24 |
合計ジャッジ時間 | 24,598 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 14 ms
9,164 KB |
testcase_01 | AC | 28 ms
5,556 KB |
testcase_02 | AC | 19 ms
4,928 KB |
testcase_03 | AC | 21 ms
5,104 KB |
testcase_04 | AC | 20 ms
5,008 KB |
testcase_05 | AC | 24 ms
5,264 KB |
testcase_06 | AC | 32 ms
6,044 KB |
testcase_07 | AC | 35 ms
6,152 KB |
testcase_08 | AC | 47 ms
7,052 KB |
testcase_09 | AC | 27 ms
5,560 KB |
testcase_10 | TLE | - |
testcase_11 | TLE | - |
testcase_12 | TLE | - |
testcase_13 | TLE | - |
testcase_14 | TLE | - |
testcase_15 | TLE | - |
testcase_16 | TLE | - |
testcase_17 | TLE | - |
testcase_18 | TLE | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
ソースコード
#include <iostream> #include <map> using namespace std; int main(int argc, char* argv[]) { int N,D; cin>>N>>D; map<int,int> xyMap; map<int,int> wzMap; map<int,int>::iterator mit; for (int x=1;x<=N;x++){ for (int y=1;y<=N;y++){ int xy=x*x+y*y; mit=xyMap.find(xy); if (mit==xyMap.end()){ xyMap[xy]=1; }else{ (*mit).second++; } int wz=x*x-y*y+D; if (wz<2){ continue; } mit=wzMap.find(wz); if (mit==wzMap.end()){ wzMap[wz]=1; }else{ (*mit).second++; } } } int ans=0; map<int,int>::iterator mit1; while (true){ mit=xyMap.begin(); if (mit==xyMap.end()){ break; } while (true){ mit1=wzMap.begin(); if (mit1==wzMap.end()){ break; } if ((*mit).first>(*mit1).first){ wzMap.erase(mit1); }else if ( (*mit).first==(*mit1).first){ ans+=(*mit).second * (*mit1).second; wzMap.erase(mit1); break; }else{ break; } } mit1=wzMap.begin(); if (mit1==wzMap.end()){ break; } xyMap.erase(mit); } xyMap.clear(); wzMap.clear(); cout<<ans<<endl; return 0; }