码迷,mamicode.com
首页 > 其他好文 > 详细

国庆个人第四场

时间:2018-10-04 21:36:38      阅读:154      评论:0      收藏:0      [点我收藏+]

标签:ast   scanf   9.png   dash   sam   files   return   最大的   nbsp   

Little C Loves 3 I

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 (3n1093≤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

Input
3
Output
1 1 1
Input
233
Output
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 }

 

 

Cover Points

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 (1n1051≤n≤105).

Each of the next nn lines contains two integers xixi and yiyi (1xi,yi1091≤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

Input
3
1 1
1 2
2 1
Output
3
Input
4
1 1
1 2
2 1
2 2
Output
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

Input
05:39
Output
11
Input
13:31
Output
0
Input
23:59
Output
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 }

 



国庆个人第四场

标签:ast   scanf   9.png   dash   sam   files   return   最大的   nbsp   

原文地址:https://www.cnblogs.com/wkfvawl/p/9743313.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!