結果
| 問題 |
No.1274 楽しい格子点
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-10-30 22:23:40 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 941 bytes |
| コンパイル時間 | 2,946 ms |
| コンパイル使用メモリ | 200,876 KB |
| 最終ジャッジ日時 | 2025-01-15 17:31:47 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 38 WA * 19 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:24: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
9 | lint a,b; scanf("%lld%lld",&a,&b);
| ~~~~~^~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using lint=long long;
int main(){
lint a,b; scanf("%lld%lld",&a,&b);
if(a<0) a*=-1;
if(b<0) b*=-1;
if((a==0 && b==0) || (a>10 && b>10)){
puts("0.25");
return 0;
}
const int OFS=100;
bool vis[200][200]={};
vis[1+OFS][1+OFS]=true;
queue<pair<int,int>> Q; Q.emplace(1,1);
while(!Q.empty()){
int x,y;
tie(x,y)=Q.front(); Q.pop();
auto update=[&](int dx,int dy){
int x2=x+dx,y2=y+dy;
if(-OFS<=x2 && x2<OFS && -OFS<=y2 && y2<OFS && !vis[x2+OFS][y2+OFS]){
vis[x2+OFS][y2+OFS]=true;
Q.emplace(x2,y2);
}
};
update( a, b);
update( a,-b);
update(-a, b);
update(-a,-b);
update( b, a);
update( b,-a);
update(-b, a);
update(-b,-a);
}
double ans=0;
for(int x=1;x<OFS;x++){
for(int y=1;y<OFS;y++){
if(vis[x+OFS][y+OFS]){
ans+=1.0/pow(x+y,x+y);
}
}
}
printf("%.15f\n",ans);
return 0;
}