結果

問題 No.781 円周上の格子点の数え上げ
ユーザー addeight2
提出日時 2019-02-08 11:11:20
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 376 ms / 2,000 ms
コード長 415 bytes
コンパイル時間 1,430 ms
コンパイル使用メモリ 157,692 KB
実行使用メモリ 81,596 KB
最終ジャッジ日時 2024-06-27 15:33:21
合計ジャッジ時間 4,549 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:11:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |         scanf("%lld %lld",&X,&Y);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
ll X,Y;
const ll MAX_Y=1e7;
ll cnt[MAX_Y+1];
int main(){
	scanf("%lld %lld",&X,&Y);
	ll r=1;
	while(r*r<=Y){
		r++;
	}
	FOR(x,-r+1,r){
		FOR(y,-r+1,r){
			if(x*x+y*y<=Y){
				cnt[x*x+y*y]++;
			}
		}
	}
	ll ans=0;
	FOR(i,X,Y+1){
		ans=max(ans,cnt[i]);
	}
	cout<<ans<<endl;
}
0