标签:for HERE you htm getting 最小 ini 题目 while
Description
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 33 integers 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.
Sample Input
3
1 1 1
233
77 77 79
题目意思:给你一个数n,要求将n分成3分,并且每一份都不能被3整除。
解题思路:直接构造就好了。目的就是为了防止出现划分出的数是3的倍数,我们就将n按照是不是3的倍数分为两类。
1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 int main() 6 { 7 int n; 8 int a,b,c; 9 scanf("%d",&n); 10 if(n%3==0) 11 { 12 a=1; 13 b=1; 14 c=n-2; 15 } 16 else if(n%3==1||n%3==2) 17 { 18 a=1; 19 b=2; 20 c=n-3; 21 } 22 printf("%d %d %d\n",a,b,c); 23 return 0; 24 }
Description
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.
Sample Input
3
1 1
1 2
2 1
3
4
1 1
1 2
2 1
2 2
4
Hint
Illustration for the first example:
Illustration for the second example:
题目意思:求一个能将所有点覆盖掉的最小等腰三角形的腰长。
解题思路:很水,找一个坐标(x,y),x+y最大的那个点的x+y值即为能够覆盖的最小等腰三角形的腰长!可以通过平移得到。
1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 int main() 6 { 7 int n,i,x,y,sum; 8 int maxs=-9999; 9 scanf("%d",&n); 10 for(i=1; i<=n; i++) 11 { 12 scanf("%d%d",&x,&y); 13 sum=x+y; 14 if(sum>maxs) 15 { 16 maxs=sum; 17 } 18 } 19 printf("%d\n",maxs); 20 return 0; 21 }
Description
Karen is getting ready for a new school day!
It is currently hh:mm, given in a 24-hour format. As you know, Karen loves palindromes, and she believes that it is good luck to wake up when the time is a palindrome.
What is the minimum number of minutes she should sleep, such that, when she wakes up, the time is a palindrome?
Remember that a palindrome is a string that reads the same forwards and backwards. For instance, 05:39 is not a palindrome, because05:39 backwards is 93:50. On the other hand, 05:50 is a palindrome, because 05:50 backwards is 05:50.
Input
The first and only line of input contains a single string in the format hh:mm (00 ≤ hh ≤ 23, 00 ≤ mm ≤ 59).
Output
Output a single integer on a line by itself, the minimum number of minutes she should sleep, such that, when she wakes up, the time is a palindrome.
Sample Input
05:39
11
13:31
0
23:59
1
Hint
In the first test case, the minimum number of minutes Karen should sleep for is 11. She can wake up at 05:50, when the time is a palindrome.
In the second test case, Karen can wake up immediately, as the current time, 13:31, is already a palindrome.
In the third test case, the minimum number of minutes Karen should sleep for is 1 minute. She can wake up at 00:00, when the time is a palindrome.
题目意思:女主角要在回文时刻起床,给你一个时刻,问到距离下一个回文时刻,女主角还能睡多久。
解题思路:开始我一直在找小时和分钟关于回文的对称关系,希望能找到规律,后来一直出错,因为会有小时进位问题,后来改成直接暴力模拟,AC。
1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 char s[10]; 6 int main() 7 { 8 int h,m,a,b; 9 int ans; 10 gets(s); 11 h=s[1]-‘0‘+(s[0]-‘0‘)*10; 12 m=s[4]-‘0‘+(s[3]-‘0‘)*10; 13 ans=0; 14 //printf("%d %d\n",h,m); 15 while(1) 16 { 17 if(m%10==h/10&&h%10==m/10)///该起床了 18 { 19 break; 20 } 21 m++; 22 ans++; 23 if(m==60) 24 { 25 m=0; 26 h++; 27 } 28 if(h==24) 29 { 30 h=0; 31 } 32 } 33 printf("%d\n",ans); 34 return 0; 35 }
标签:for HERE you htm getting 最小 ini 题目 while
原文地址:https://www.cnblogs.com/wkfvawl/p/9746816.html