Submission #61798182


Source Code Expand

Copy
#include<bits/stdc++.h>
#define Withers using
#define AK namespace
#define IOI std
#define int long long
Withers AK IOI;typedef long long ll;typedef pair<int,int>pii;int n,m,u,v,w,x,y,z,l,r,minn=INT_MAX,maxx=INT_MIN,k;int tst;int a[200010];char s[200010];mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());char t[200010];
#define infll 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define endl '\n'
static char buf[1<<18],*paa=buf,*pddd=buf;static char buf2[1<<18],*pppp=buf2;
#define getchar()paa==pddd&&(pddd=(paa=buf)+fread(buf,1,1<<18,stdin),paa==pddd)?EOF:*paa++
inline void pc(char ch){if(pppp-buf2==1<<18)fwrite(buf2,1,1<<18,stdout),pppp=buf2;*pppp++=ch;}inline void pcc(){fwrite(buf2,1,pppp-buf2,stdout);pppp=buf2;}inline void rd(int&n){int w=1;register int x(0);register char c(getchar());while(c<'0'||c>'9'){if(c=='-')w=-1;c=getchar();}while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();n=w*x;return;}inline void write(int x){if(x<0)pc('-'),x=-x;static int sta[20];int top=0;do{sta[top++]=x%10,x/=10;}while(x);while(top)pc(sta[--top]+48);}inline void we(int x){write(x);pc('\n');}inline void ws(int x){write(x);pc(' ');}
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define deb(x)cout<<#x<<"="<<x<<" ";
#define pb push_back
#define fi first
#define se second
#define mx3(a,b,c)((a>b?a:b)>c?(a>b?a:b):c)
#define mn3(a,b,c)((a<b?a:b)<c?(a<b?a:b):c)
#define mem(a,b)memset(a,b,sizeof(a))
 
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include<bits/stdc++.h>
#define Withers using
#define AK namespace
#define IOI std
#define int long long
Withers AK IOI;typedef long long ll;typedef pair<int,int>pii;int n,m,u,v,w,x,y,z,l,r,minn=INT_MAX,maxx=INT_MIN,k;int tst;int a[200010];char s[200010];mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());char t[200010];
#define infll 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define endl '\n'
static char buf[1<<18],*paa=buf,*pddd=buf;static char buf2[1<<18],*pppp=buf2;
#define getchar()paa==pddd&&(pddd=(paa=buf)+fread(buf,1,1<<18,stdin),paa==pddd)?EOF:*paa++
inline void pc(char ch){if(pppp-buf2==1<<18)fwrite(buf2,1,1<<18,stdout),pppp=buf2;*pppp++=ch;}inline void pcc(){fwrite(buf2,1,pppp-buf2,stdout);pppp=buf2;}inline void rd(int&n){int w=1;register int x(0);register char c(getchar());while(c<'0'||c>'9'){if(c=='-')w=-1;c=getchar();}while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();n=w*x;return;}inline void write(int x){if(x<0)pc('-'),x=-x;static int sta[20];int top=0;do{sta[top++]=x%10,x/=10;}while(x);while(top)pc(sta[--top]+48);}inline void we(int x){write(x);pc('\n');}inline void ws(int x){write(x);pc(' ');}
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define deb(x)cout<<#x<<"="<<x<<" ";
#define pb push_back
#define fi first
#define se second
#define mx3(a,b,c)((a>b?a:b)>c?(a>b?a:b):c)
#define mn3(a,b,c)((a<b?a:b)<c?(a<b?a:b):c)
#define mem(a,b)memset(a,b,sizeof(a))
#define rep(i,a,b)for(int i=a;i<=b;i++)
void rd(int n,int a[]){for(int i=1;i<=n;i++)rd(a[i]);}void rda(){rd(n);for(int i=1;i<=n;i++)rd(a[i]);}void adde(vector<pii>g[],int x,int y,int z){g[x].push_back({y,z});g[y].push_back({x,z});}
int get(char s[]){char ch=' ';int cnt=0;int len=strlen(s+1);for(int i=1;i<=len;i++)s[i]=0;while(ch==' '||ch=='\n'||ch=='\r'||ch==EOF)ch=getchar();while(!(ch==' '||ch=='\n'||ch=='\r'||ch==EOF))s[++cnt]=ch,ch=getchar();return cnt;}void put(char s[]){int len=strlen(s+1);for(int i=1;i<=len;i++)pc(s[i]);}void get(string&s){s="";char ch=' ';while(ch==' '||ch=='\n'||ch=='\r'||ch==EOF)ch=getchar();while(!(ch==' '||ch=='\n'||ch=='\r'||ch==EOF))s.push_back(ch),ch=getchar();return;}void put(string s){int len=s.size();for(int i=0;i<len;i++)pc(s[i]);}void file(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
void solve()
{
	//do something
	rd(x);
	int ans=0;
	rep(i,0,x-1)
	{
		double p=i+0.5;
		int q=floor(sqrtl(x*x-p*p)-0.5);
		ans+=max(0ll,(int)q);
	}
	cout<<ans*4+1<<endl;
}
void multi()
{
	//rd(tst);
	tst=1;
	while(tst--)
	{
		solve();
	}
	pcc();
}
signed main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	multi();
}
// POWERED BY WITHERS
// THINK ONCE, CODE TWICE
/*things to check
1.  int overflow or long long memory need
2.  recursion/array/binary search/dp/loop bounds
3.  precision
4.  special cases(n=1,bounds)
5.  delete debug statements
6.  initialize(especially multi-tests)
7.  = or == , n or m ,++ or -- , i or j , > or >= , < or <= , - or =
8.  keep it simple and stupid
9.  do not delete, use // instead
10. operator priority
11. is there anything extra to output?
12. if you don't know where the bug is , try to clear some parts of the code
 and check each part seperately.
13. ...
*/
 
/* something to think about
1. greedy? dp? searching? dp with matrix/ segment tree? binary search?
2. If contains "not", why not 正难则反 or few affect?
*/
// lgvc bilibilitdasc zxx zy graygoo tt cyx wsc akioi!

Submission Info

Submission Time
Task D - Squares in Circle
User Withers
Language C++ 20 (gcc 12.2)
Score 400
Code Size 3504 Byte
Status AC
Exec Time 8 ms
Memory 3672 KB

Compile Error

Main.cpp: In function ‘void rd(long long int&)’:
Main.cpp:12:199: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   12 | inline void pc(char ch){if(pppp-buf2==1<<18)fwrite(buf2,1,1<<18,stdout),pppp=buf2;*pppp++=ch;}inline void pcc(){fwrite(buf2,1,pppp-buf2,stdout);pppp=buf2;}inline void rd(int&n){int w=1;register int x(0);register char c(getchar());while(c<'0'||c>'9'){if(c=='-')w=-1;c=getchar();}while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();n=w*x;return;}inline void write(int x){if(x<0)pc('-'),x=-x;static int sta[20];int top=0;do{sta[top++]=x%10,x/=10;}while(x);while(top)pc(sta[--top]+48);}inline void we(int x){write(x);pc('\n');}inline void ws(int x){write(x);pc(' ');}
      |                                                                                                                                                                                                       ^
Main.cpp:12:218: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   12 | inline void pc(char ch){if(pppp-buf2==1<<18)fwrite(buf2,1,1<<18,stdout),pppp=buf2;*pppp++=ch;}inline void pcc(){fwrite(buf2,1,pppp-buf2,stdout);pppp=buf2;}inline void rd(int&n){int w=1;register int x(0);register char c(getchar());while(c<'0'||c>'9'){if(c=='-')w=-1;c=getchar();}while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();n=w*x;return;}inline void write(int x){if(x<0)pc('-'),x=-x;static int sta[20];int top=0;do{sta[top++]=x%10,x/=10;}while(x);while(top)pc(sta[--top]+48);}inline void we(int x){write(x);pc('\n');}inline void ws(int x){write(x);pc(' ');}
      |                                                                                                                                                                                                                          ^
Main.cpp: In function ‘void file(std::string)’:
Main.cpp:24:572: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   24 | int get(char s[]){char ch=' ';int cnt=0;int len=strlen(s+1);for(int i=1;i<=len;i++)s[i]=0;while(ch==' '||ch=='\n'||ch=='\r'||ch==EOF)ch=getchar();while(!(ch==' '||ch=='\n'||ch=='\r'||ch==EOF))s[++cnt]=ch,ch=getchar();return cnt;}void put(char s[]){int len=strlen(s+1);for(int i=1;i<=len;i++)pc(s[i]);}void get(string&s){s="";char ch=' ';while(ch==' '||ch=='\n'||ch=='\r'||ch==EOF)ch=getchar();while(!(ch==' '||ch=='\n'||ch=='\r'||ch==EOF))s.push_back(ch),ch=getchar();return;}void put(string s){int len=s.size();for(int i=0;i<len;i++)pc(s[i]);}void file(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:24:609: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   24 | int get(char s[]){char ch=' ';int cnt=0;int len=strlen(s+1);for(int i=1;i<=len;i++)s[i]=0;while(ch==' '||ch=='\n'||ch=='\r'||ch==EOF)ch=getchar();while(!(ch==' '||ch=='\n'||ch=='\r'||ch==EOF))s[++cnt]=ch,ch=getchar();return cnt;}void put(char s[]){int len=strlen(s+1);for(int i=1;i<=len;i++)pc(s[i]);}void get(string&s){s="";char ch=' ';while(ch==' '||ch=='\n'||ch=='\r'||ch==EOF)ch=getchar();while(!(ch==' '||ch=='\n'||ch=='\r'||ch==EOF))s.push_back(ch),ch=getchar();return;}void put(string s){int len=s.size();for(int i=0;i<len;i++)pc(s[i]);}void file(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 25
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3572 KB
00_sample_01.txt AC 1 ms 3572 KB
00_sample_02.txt AC 1 ms 3672 KB
01_random_00.txt AC 3 ms 3492 KB
01_random_01.txt AC 7 ms 3500 KB
01_random_02.txt AC 4 ms 3500 KB
01_random_03.txt AC 7 ms 3500 KB
01_random_04.txt AC 5 ms 3524 KB
01_random_05.txt AC 6 ms 3584 KB
01_random_06.txt AC 7 ms 3504 KB
01_random_07.txt AC 2 ms 3544 KB
01_random_08.txt AC 6 ms 3520 KB
01_random_09.txt AC 1 ms 3516 KB
01_random_10.txt AC 8 ms 3548 KB
01_random_11.txt AC 8 ms 3444 KB
01_random_12.txt AC 8 ms 3416 KB
01_random_13.txt AC 7 ms 3548 KB
01_random_14.txt AC 7 ms 3412 KB
01_random_15.txt AC 8 ms 3536 KB
01_random_16.txt AC 7 ms 3516 KB
01_random_17.txt AC 8 ms 3552 KB
01_random_18.txt AC 8 ms 3508 KB
01_random_19.txt AC 8 ms 3412 KB
01_random_20.txt AC 1 ms 3524 KB
01_random_21.txt AC 7 ms 3408 KB


2025-03-05 (Wed)
18:06:07 +00:00