A. Little C Loves 3 I
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Little C loves number «3» very much. He loves all things about it.
Now he has a positive integer nn. He wants to split nn into 33 positive integers a,b,ca,b,c, such that a+b+c=na+b+c=n and none of the 33integers is a multiple of 33. Help him to find a solution.
Input
A single line containing one integer nn (3≤n≤1093≤n≤109) — the integer Little C has.
Output
Print 33 positive integers a,b,ca,b,c in a single line, such that a+b+c=na+b+c=n and none of them is a multiple of 33.
It can be proved that there is at least one solution. If there are multiple solutions, print any of them.
Examples
input
Copy
3
output
Copy
1 1 1
input
Copy
233
output
Copy
77 77 79
题意 给你n个数 让你拆成三个数 并且这三个数不能是3的倍数 水题
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;
int main()
{
int n;
cin>>n;
cout<<1<<" ";
if((n-2)%3!=0)
cout<<1<<" "<<n-2;
else
cout<<2<<" "<<n-3;
return 0;
}
B. Cover Points
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
There are nn points on the plane, (x1,y1),(x2,y2),…,(xn,yn)(x1,y1),(x2,y2),…,(xn,yn).
You need to place an isosceles triangle with two sides on the coordinate axis to cover all points (a point is covered if it lies inside the triangle or on the side of the triangle). Calculate the minimum length of the shorter side of the triangle.
Input
First line contains one integer nn (1≤n≤1051≤n≤105).
Each of the next nn lines contains two integers xixi and yiyi (1≤xi,yi≤1091≤xi,yi≤109).
Output
Print the minimum length of the shorter side of the triangle. It can be proved that it's always an integer.
Examples
input
Copy
3
1 1
1 2
2 1
output
Copy
3
input
Copy
4
1 1
1 2
2 1
2 2
output
Copy
4
Note
Illustration for the first example:
Illustration for the second example:
题意:在二维坐标系中给你n个点 问将所有点都包在里面的最短截距。。差不多就是这个意思吧 因为要构成一个等腰直角三角形 所以x,y相等
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;
int main()
{
int n;
cin>>n;
int maxx=-1;
for(int i=1;i<=n;i++)
{
int x,y;
cin>>x>>y;
x=x+y;
maxx=max(x,maxx);
}
cout<<maxx<<endl;
return 0;
}
C. Enlarge GCD
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Mr. F has nn positive integers, a1,a2,…,ana1,a2,…,an.
He thinks the greatest common divisor of these integers is too small. So he wants to enlarge it by removing some of the integers.
But this problem is too simple for him, so he does not want to do it by himself. If you help him, he will give you some scores in reward.
Your task is to calculate the minimum number of integers you need to remove so that the greatest common divisor of the remaining integers is bigger than that of all integers.
Input
The first line contains an integer nn (2≤n≤3⋅1052≤n≤3⋅105) — the number of integers Mr. F has.
The second line contains nn integers, a1,a2,…,ana1,a2,…,an (1≤ai≤1.5⋅1071≤ai≤1.5⋅107).
Output
Print an integer — the minimum number of integers you need to remove so that the greatest common divisor of the remaining integers is bigger than that of all integers.
You should not remove all of the integers.
If there is no solution, print «-1» (without quotes).
Examples
input
Copy
3
1 2 4
output
Copy
1
input
Copy
4
6 9 15 30
output
Copy
2
input
Copy
3
1 1 1
output
Copy
-1
Note
In the first example, the greatest common divisor is 11 in the beginning. You can remove 11 so that the greatest common divisor is enlarged to 22. The answer is 11.
In the second example, the greatest common divisor is 33 in the beginning. You can remove 66 and 99 so that the greatest common divisor is enlarged to 1515. There is no solution which removes only one integer. So the answer is 22.
In the third example, there is no solution to enlarge the greatest common divisor. So the answer is −1−1.
题意:给你n个数 他们的最大公约数为gcd 求要使最大公约数变大 最少需要剔除多少个数
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;
int a[15000010];
int p[15000010];
int gcd(int a,int b)
{
if(!b)
return a;
return gcd(b,a%b);
}
int main()
{
int n;
scanf("%d",&n); //cin 会超时
int g=0;
int maxx=-1;
memset(a,0,sizeof(a));
memset(p,0,sizeof(p));
for(int i=1;i<=n;i++)
{
int c;
scanf("%d",&c);
a[c]++;
if(!g)
g=c;
else
g=gcd(g,c);
maxx=max(maxx,c);
}
int h=n;
for(int i=g+1;i<=maxx;i++)
{
if(!p[i])
{
int cnt=0;
for(int j=i;j<=maxx;j+=i)
{
p[j]=1,cnt+=a[j];
}
h=min(h,n-cnt);
}
}
if(h==n)
cout<<-1<<endl;
else
cout<<h<<endl;
return 0;
}