Guwanch1's blog

By Guwanch1, history, 3 years ago, In English

Hello, can you explain how to solve this problem, please?

Problem

Thank you!

  • Vote: I like it
  • +1
  • Vote: I do not like it

| Write comment?
»
3 years ago, # |
  Vote: I like it +3 Vote: I do not like it

What is the data range of n?

»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Check this problem. The solution to this one is similar to your problem.

»
3 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Oh, maybe I solved it.

Code:

#include<bits/stdc++.h>
#define db double 
using namespace std;
db r; int n,cntnow,cntres,cntpoi;
int main(){
 scanf("%d",&n);
 r=(n-1)*0.5,n>>=1;
 for(int i=n;i>0;i--) if(r>i){
 cntnow+=(int)sqrt(r*r-i*i);
 cntpoi+=(int)sqrt(r*r-i*i);
 }
 cntres=(n-1)*(n-1)-cntpoi;
 printf("%d\n",cntnow*4);
 printf("%d",(n*n-cntnow-cntres)*4);
 return 0;
}