結果
問題 | No.781 円周上の格子点の数え上げ |
ユーザー |
|
提出日時 | 2019-04-06 00:31:45 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 143 ms / 2,000 ms |
コード長 | 544 bytes |
コンパイル時間 | 732 ms |
コンパイル使用メモリ | 127,616 KB |
実行使用メモリ | 42,880 KB |
最終ジャッジ日時 | 2024-11-30 14:00:58 |
合計ジャッジ時間 | 1,821 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 |
ソースコード
#include <iostream> #include <math.h> constexpr int MAX_SIZE = 1e7+1; int datum[MAX_SIZE] = {}; int main(void){ int x, y, max = 0;scanf("%d %d", &x, &y); int i = 0, ii = 0, j, jj; while((ii = i * i) <= y){ // ii * j * j >= x ~> const int edge = x - ii; j = floor(sqrt(x - ii)); while((jj = j * j) < edge) j++; while((jj = j * j) <= y - ii){ datum[ii + jj] += (i == 0 or j == 0) ? 2 : 4; j++; } i++; } for(int i = x; i <= y; i++) if(max < datum[i]) max = datum[i]; printf("%d\n", max); return 0; }