o.boj 1066 SPOJ

编程入门 行业动态 更新时间:2024-10-16 08:23:59

o.<a href=https://www.elefans.com/category/jswz/34/1716625.html style=boj 1066 SPOJ"/>

o.boj 1066 SPOJ

注:最近这一系列ACM的内容,都是2年多之前的代码,自己回顾一下。
PATULJCI
Submit: 1156   Accepted:704
Time Limit: 1000MS  Memory Limit: 65535K

Description

Every day, while the dwarves are busy in the mines, Snow White prepares dinner for them; seven chairs, seven plates, seven forks and seven knives for seven hungry dwarves. One day nine dwarves came from the mines instead of seven (nobody knows how or why), each of them claiming to be one of Snow White's seven dwarves. Luckily, each dwarf wears a hat with a positive integer less than 100 written on it. Snow White, a famous mathematician, realised long ago that the sum of numbers on the hats of her seven dwarves was exactly 100. Write a program which determines which dwarves are legit, i.e. pick seven of nine numbers that add to 100.

Input

There are 9 lines of input. Each contains an integer between 1 and 99 (inclusive). All of the numbers will be distinct. Note: The test data will be such that the solution is unique.

Output

Your program must produce exactly seven lines of output – the numbers on the hats of Snow White's seven dwarves. Output the numbers in any order.

Sample Input 7

8

10

13

15

19

20

23

25

Sample Output7

8

10

13

19

20

23



Source Croatian Open Competition in Informatics

七个小矮人突然变成九个小矮人了,但真正的七个小矮人头上的编号加起来刚好是100,计算出哪些是真正的小矮人。方法很简单,先算出9个数之和,减100,则为多出来那两个数的和,然后计算是哪两个数之和。
 
模拟题
#include <stdio.h>main()
{char time[6];int N, num, ht, mt, money = 0;scanf("%d", &N);while (N--){scanf("%s", time);ht = (time[0] - 48) * 10 + time[1] - 48;mt = (time[3] - 48) * 10 + time[4] - 48;scanf("%d", &num);if (ht >= 7 && ht < 19){if ((ht + (mt + num)/60) == 19)money += ((mt + num)%60*5 + (60-mt)*10);                elsemoney += (num * 10);}else{if ((ht + (mt + num)/60) == 7)money += (((mt + num)%60)*10 + (60 - mt)*5);elsemoney += (num * 5);}}printf("%d\n", money);// system("pause");return 0;
}


更多推荐

o.boj 1066 SPOJ

本文发布于:2024-02-06 15:37:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1749877.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:boj   SPOJ

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!