版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/lv414333532/article/details/52045280
Sqrt Bo
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 730 Accepted Submission(s): 341
Total Submission(s): 730 Accepted Submission(s): 341
开根向下取整;
Problem Description
Problem Description
Let's define the function
f(n)=⌊n−−√⌋.
Bo wanted to know the minimum number y which satisfies fy(n)=1.
note: f1(n)=f(n),fy(n)=f(fy−1(n))
It is a pity that Bo can only use 1 unit of time to calculate this function each time.
And Bo is impatient, he cannot stand waiting for longer than 5 units of time.
So Bo wants to know if he can solve this problem in 5 units of time.
Bo wanted to know the minimum number y which satisfies fy(n)=1.
note: f1(n)=f(n),fy(n)=f(fy−1(n))
It is a pity that Bo can only use 1 unit of time to calculate this function each time.
And Bo is impatient, he cannot stand waiting for longer than 5 units of time.
So Bo wants to know if he can solve this problem in 5 units of time.
Input
This problem has multi test cases(no more than
120).
Each test case contains a non-negative integer n(n<10100).
Each test case contains a non-negative integer n(n<10100).
Output
For each test case print a integer - the answer
y or a string "TAT" - Bo can't solve this problem.
Sample Input
233 233333333333333333333333333333333333333333333333333333333
Sample Output
3 TAT
Source
Recommend
wange2014 | We have carefully selected several similar problems for you:
5761
5760
5759
5758
5757
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#define LL long long
using namespace std;
char s[210];
LL ans;
LL A[]={1,(1<<2)-1,(1<<4)-1,(1<<8)-1,(1<<16)-1,(1LL<<32)-1};
int main()
{
//cout<<A[5]<<endl;
while(~scanf("%s",s))
{
if(strlen(s)>10||strlen(s)==1&&s[0]=='0')
printf("TAT\n");
else
{
ans=0;
for(int i=0;s[i];i++)
ans=ans*10+s[i]-'0';
if(ans>A[5])
printf("TAT\n");
else
printf("%d\n",lower_bound(A,A+6,ans)-A);
}
}
return 0;
}
Permutation Bo
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 508 Accepted Submission(s): 301
Special Judge
Total Submission(s): 508 Accepted Submission(s): 301
Special Judge
求系数;
Problem Description
Problem Description
There are two sequences
h1∼hn and
c1∼cn.
h1∼hn is a permutation of
1∼n. particularly,
h0=hn+1=0.
We define the expression [condition] is 1 when condition is True,is 0 when condition is False.
Define the function f(h)=∑ni=1ci[hi>hi−1 and hi>hi+1]
Bo have gotten the value of c1∼cn, and he wants to know the expected value of f(h).
We define the expression [condition] is 1 when condition is True,is 0 when condition is False.
Define the function f(h)=∑ni=1ci[hi>hi−1 and hi>hi+1]
Bo have gotten the value of c1∼cn, and he wants to know the expected value of f(h).
Input
This problem has multi test cases(no more than
12).
For each test case, the first line contains a non-negative integer n(1≤n≤1000), second line contains n non-negative integer ci(0≤ci≤1000).
For each test case, the first line contains a non-negative integer n(1≤n≤1000), second line contains n non-negative integer ci(0≤ci≤1000).
Output
For each test cases print a decimal - the expectation of
f(h).
If the absolute error between your answer and the standard answer is no more than 10−4, your solution will be accepted.
If the absolute error between your answer and the standard answer is no more than 10−4, your solution will be accepted.
Sample Input
4 3 2 4 5 5 3 5 99 32 12
Sample Output
6.000000 52.833333
Source
Recommend
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define LL long long
using namespace std;
LL A[1010]={0};
LL sum[1010]={0};
int main()
{
int n;
for(int i=2;i<1010;i++)
A[i]=(LL)(i-1)*(i-2)*(i);
LL ans1,ans2;
int x;
LL ans=0;
for(int i=3;i<1010;i++)
{
ans+=(LL)(i-2);
sum[i]=sum[i-1]+ans*2;
}
while(~scanf("%d",&n))
{
ans1=ans2=0;
for(int i=1;i<=n;i++)
{
scanf("%d",&x);
if(i!=n&&i!=1)
ans2+=x;
else
ans1+=x;
}
if(n==1)
{
printf("%.10f\n",(double)ans1);
continue;
}
else
{
double tmp=(double)ans1/2.0;
if(n>2)
tmp+=+ans2*(sum[n])/(double)(A[n]);
printf("%.10f\n",tmp);
}
}
return 0;
}
Teacher Bo
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 691 Accepted Submission(s): 381
Total Submission(s): 691 Accepted Submission(s): 381
循环不会超过2*M;
Problem Description
Problem Description
Teacher BoBo is a geography teacher in the school.One day in his class,he marked
N points in the map,the
i-th point is at
(Xi,Yi).He wonders,whether there is a tetrad
(A,B,C,D)(A<B,C<D,A≠CorB≠D) such that the manhattan distance between A and B is equal to the manhattan distance between C and D.
If there exists such tetrad,print "YES",else print "NO".
If there exists such tetrad,print "YES",else print "NO".
Input
First line, an integer
T. There are
T test cases.
(T≤50)
In each test case,the first line contains two intergers, N, M, means the number of points and the range of the coordinates. (N,M≤105).
Next N lines, the i-th line shows the coordinate of the i-th point. (Xi,Yi)(0≤Xi,Yi≤M).
In each test case,the first line contains two intergers, N, M, means the number of points and the range of the coordinates. (N,M≤105).
Next N lines, the i-th line shows the coordinate of the i-th point. (Xi,Yi)(0≤Xi,Yi≤M).
Output
T lines, each line is "YES" or "NO".
Sample Input
2 3 10 1 1 2 2 3 3 4 10 8 8 2 3 3 3 4 4
Sample Output
YES NO
Source
Recommend
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <algorithm>
#define LL long long
using namespace std;
const int N=1e5+10;
struct node
{
int x,y;
bool operator <(const node &A)const
{
return (x==A.x&&y<A.y||x<A.x)?1:0;
}
bool operator ==(const node &A)const
{
return (x==A.x&&y==A.y)?1:0;
}
}que[N];
int dis[N<<2];
int n,m;
bool slove()
{
memset(dis,0,sizeof(dis));
for(int i=0;i<n;i++)
{
for(int j=i+1;j<n;j++)
{
int d=abs(que[i].x-que[j].x)+abs(que[i].y-que[j].y);
dis[d]++;
if(dis[d]>1)
return 1;
}
}
return 0;
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&n,&m);
for(int i=0;i<n;i++)
{
scanf("%d%d",&que[i].x,&que[i].y);
}
// if(sqrt(m)<=n)
// {
// printf("YES\n");
// continue;
// }
sort(que,que+n);
n=unique(que,que+n)-que;
if(slove())
printf("YES\n");
else
printf("NO\n");
}
return 0;
}