7-1 A+B 输入输出练习 (VIII) （15 分）

3
4 1 2 3 4
5 1 2 3 4 5
3 1 2 3

10

15

6

1个回答

``````#include "stdio.h"
#include "stdlib.h"

int main()
{
int n;
scanf("%d", &n);
int * sum = (int *)malloc(sizeof(int) * n);
for (int i = 0; i < n; i++)
{
int m, x;
sum[i] = 0;
scanf("%d", &m);
for (int j = 0; j < m; j++)
{
scanf("%d", &x);
sum[i] += x;
}
}
for (int i = 0; i < n; i++)
printf("%d\n", sum[i]);
free(sum);
return 0;
}
``````

`如果问题得到解决，请点我回答左上角的采纳和向上的箭头，谢谢`

7-1 A+B 输入输出练习 (VIII) （15 分）

What Day Is It? 的解答
Problem Description The calendar now in use evolved from the Romans. Julius Caesar codified a calendar system that came to be known as the Julian calendar. In this system, all months have 31 days, except for April, June, September, and November, which have 30 days, and February, which has 28 days in non-leap years, and 29 days in leap years. Also, in this system, leap years happened every four years. That is because the astronomers of ancient Rome computed the year to be 365.25 days long, so that after every four years, one needed to add an extra day to keep the calendar on track with the seasons. To do this, they added an extra day (February 29) to every year that was a multiple of four. Julian Rule: Every year that is a multiple of 4 is a leap year, i.e. has an extra day (February 29). In 1582, Pope Gregory's astronomers noticed that the year was not 365.25 days long, but closer to 365.2425. Therefore, the leap year rule would be revised to the following: Gregorian Rule: Every year that is a multiple of 4 is a leap year, unless it is a multiple of 100 that is not a multiple of 400. To compensate for how the seasons had shifted against the calendar up until that time, the calendar was actually shifted 10 days: the day following October 4, 1582 was declared to be October 15. England and its empire (including the United States) didn't switch to the Gregorian calendar system until 1752, when the day following September 2 was declared to be September 14. (The delay was caused by the poor relationship between Henry VIII and the Pope.) Write a program that converts dates in the United States using a calendar of the time and outputs weekdays. Input The input will be a series of positive integers greater than zero, three integers per line, which represent dates, one date per line. The format for a date is ``month day year" where month is a number between 1 (which indicates January) and 12 (which indicates December), day is a number between 1 and 31, and year is positive number. Output The output will be the input date and name of the weekday on which the given date falls in the format shown in the sample. An invalid date or nonexistent date for the calendar used in the United States at the time should generate an error message indicating a invalid date. The input will end with three zeroes Sample Input 11 15 1997 1 1 2000 7 4 1998 2 11 1732 9 2 1752 9 14 1752 4 33 1997 0 0 0 Sample Output November 15, 1997 is a Saturday January 1, 2000 is a Saturday July 4, 1998 is a Saturday February 11, 1732 is a Friday September 2, 1752 is a Wednesday September 14, 1752 is a Thursday 4/33/1997 is an invalid date.
What Day Is It? 的问题
Problem Description The calendar now in use evolved from the Romans. Julius Caesar codified a calendar system that came to be known as the Julian calendar. In this system, all months have 31 days, except for April, June, September, and November, which have 30 days, and February, which has 28 days in non-leap years, and 29 days in leap years. Also, in this system, leap years happened every four years. That is because the astronomers of ancient Rome computed the year to be 365.25 days long, so that after every four years, one needed to add an extra day to keep the calendar on track with the seasons. To do this, they added an extra day (February 29) to every year that was a multiple of four. Julian Rule: Every year that is a multiple of 4 is a leap year, i.e. has an extra day (February 29). In 1582, Pope Gregory's astronomers noticed that the year was not 365.25 days long, but closer to 365.2425. Therefore, the leap year rule would be revised to the following: Gregorian Rule: Every year that is a multiple of 4 is a leap year, unless it is a multiple of 100 that is not a multiple of 400. To compensate for how the seasons had shifted against the calendar up until that time, the calendar was actually shifted 10 days: the day following October 4, 1582 was declared to be October 15. England and its empire (including the United States) didn't switch to the Gregorian calendar system until 1752, when the day following September 2 was declared to be September 14. (The delay was caused by the poor relationship between Henry VIII and the Pope.) Write a program that converts dates in the United States using a calendar of the time and outputs weekdays. Input The input will be a series of positive integers greater than zero, three integers per line, which represent dates, one date per line. The format for a date is ``month day year" where month is a number between 1 (which indicates January) and 12 (which indicates December), day is a number between 1 and 31, and year is positive number. Output The output will be the input date and name of the weekday on which the given date falls in the format shown in the sample. An invalid date or nonexistent date for the calendar used in the United States at the time should generate an error message indicating a invalid date. The input will end with three zeroes Sample Input 11 15 1997 1 1 2000 7 4 1998 2 11 1732 9 2 1752 9 14 1752 4 33 1997 0 0 0 Sample Output November 15, 1997 is a Saturday January 1, 2000 is a Saturday July 4, 1998 is a Saturday February 11, 1732 is a Friday September 2, 1752 is a Wednesday September 14, 1752 is a Thursday 4/33/1997 is an invalid date.
The Umbrella Problem: 2054 C语言
Description "Forget it," Garret complained, throwing down the controller to his PlayStation VIII, "this level is impossible." He had just "died" for the 17th time on level 54 of the game "Lemmings 9: Lost in Space". "No it isn't," his brother Ferret replied, "and I can prove it." Ferret pulled his PlaySkool PDA from the back pocket of his Levi's Huggies. "First, picture the level as a rectangular grid." Ferret punched a few of the buttons on his PDA and a rectangle appeared as he described. "Your character, a Lemming holding an umbrella, starts at the top of this rectangle. His goal is to reach the bottom without dying." "I know that, you weasel, but what about the laser guns?" Garret whined. "The name is Ferret, and I was just getting to that. If we represent the level as a rectangular grid, then the Lemming can occupy one square and each laser gun can occupy a square. Remember the laser guns are cyclic: they all shoot up the first turn, right the second turn, down the third turn, left the fourth turn, and then repeat the sequence." "But you're forgetting the pits of lava!" Garret exclaimed. "You didn't let me finish. Each pit of lava also occupies a square. And each plot of grass, the Lemming's destination, can also occupy a square. Then, it's just a matter of manipulating the Lemming and laser beams in a series of turns to determine if it is possible for the Lemming to reach the bottom without 'dying'." "You think you're so smart, Ferret, let's see if you can explain that again in a clear, concise way." "Certainly": The level will consist of a grid of squares. The way each laser beam and the Lemming moves can be described in "turns". To determine if the Lemming can reach the bottom of the level without dying, Ferret devised some rules: Each turn will consist of two steps: First, the laser guns will "fire" and maintain until the end of the turn, a beam in a direction dependent on the number of the turn. On the first turn, each laser gun will shoot up (all squares directly above a laser gun are "unsafe" and cannot be occupied by the Lemming); on the second turn, each laser gun will shoot right; on the third turn, each laser gun will shoot down; on the fourth turn, each laser gun will shoot left; on the fifth turn, the sequence will repeat. Example: Column 01234 R 0| L |<- The Lemming will always start in a column on row 0 o 1| | In this example, on the first turn, the laser beam w 2| S | will occupy squares (3,0),(3,1); second turn, (4,2); 3| | third turn, (3,3),(3,4),(3,5),(3,6); fourth turn, 4| | (0,2),(1,2),(2,2); fifth turn (repeating), (3,0),(3,1), etc. 5| | (squares are represented using (column,row) notation) 6|GPPGG|<- The pits of lava and grass squares will always be in the last row Second, the Lemming will always move one row down, but to any one of three columns: one column to the left, one column to the right, or remain in the same column. In the above example, on the first turn the Lemming (L) could move to square (1,1), (2,1), or (3,1) (if he moved to (3,1), though, he would die because of the laser beam). However, on any turn the Lemming cannot move outside of the grid (i.e., he cannot move to column -1, or to a column number equal to the number of columns). The level is considered "possible" if the Lemming can reach any "grass" square without dying after a series of turns. The Lemming will die if at any point he occupies the same square as a laser gun, its beam, or a pit of lava. This includes: The Lemming moving into a square a pit of lava occupies, The Lemming moving into a square a laser gun occupies, The Lemming moving into a square a laser beam occupies (even if it is a grass square!), A laser gun firing a beam into a square the Lemming occupies Input Input to this problem will consist of a (non-empty) series of up to 100 data sets. Each data set will be formatted according to the following description, and there will be no blank lines separating data sets. Each data set will describe the starting conditions of the level. A single data set has the following components: Start line - A single line, "START x y", where 0 < x < 10 and x is the number of columns in the grid representing the level and 1 < y < 10 and y is the number of rows in the grid representing the level. The next y lines will represent the rows of the level, starting with row 0 (the top). Each line will consist of x letters. The letters will represent components of the level as follows: L - Lemming (there will only be one 'L' per data set, and it will always be in row 0) S - laser gun (these squares will never be in the final row) P - pit of lava (these squares will always be in the final row) G - grass (these squares will also always be in the final row) O - "empty" square of air End line -- A single line, "END". Following the final data set will be a single line, "ENDOFINPUT". Output Output for each data set will be exactly one line. The line will either be "FERRET" or "GARRET" (both all caps with no whitespace leading or following). "FERRET" will appear if the Lemming can make it safely (without dying) to any grass square at the bottom of the level after a series of turns. "GARRET" will be output for a data set if it fails to meet the criteria for a "FERRET" line. Sample Input START 5 7 OOLOO OOOOO OOOSO OOOOO OOOOO OOOOO GPPGG END START 3 3 OLO OSO GGG END START 5 8 LOOOS OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO PPPPG END ENDOFINPUT Sample Output FERRET GARRET GARRET

What Day Is It?
The calendar now in use evolved from the Romans. Julius Caesar codified a calendar system that came to be known as the Julian calendar. In this system, all months have 31 days, except for April, June, September, and November, which have 30 days, and February, which has 28 days in non-leap years, and 29 days in leap years. Also, in this system, leap years happened every four years. That is because the astronomers of ancient Rome computed the year to be 365.25 days long, so that after every four years, one needed to add an extra day to keep the calendar on track with the seasons. To do this, they added an extra day (February 29) to every year that was a multiple of four. Julian Rule: Every year that is a multiple of 4 is a leap year, i.e. has an extra day (February 29). In 1582, Pope Gregory's astronomers noticed that the year was not 365.25 days long, but closer to 365.2425. Therefore, the leap year rule would be revised to the following: Gregorian Rule: Every year that is a multiple of 4 is a leap year, unless it is a multiple of 100 that is not a multiple of 400. To compensate for how the seasons had shifted against the calendar up until that time, the calendar was actually shifted 10 days: the day following October 4, 1582 was declared to be October 15. England and its empire (including the United States) didn't switch to the Gregorian calendar system until 1752, when the day following September 2 was declared to be September 14. (The delay was caused by the poor relationship between Henry VIII and the Pope.) Write a program that converts dates in the United States using a calendar of the time and outputs weekdays. Input The input will be a series of positive integers greater than zero, three integers per line, which represent dates, one date per line. The format for a date is ``month day year" where month is a number between 1 (which indicates January) and 12 (which indicates December), day is a number between 1 and 31, and year is positive number. Output The output will be the input date and name of the weekday on which the given date falls in the format shown in the sample. An invalid date or nonexistent date for the calendar used in the United States at the time should generate an error message indicating a invalid date. The input will end with three zeroes. Sample Input 11 15 1997 1 1 2000 7 4 1998 2 11 1732 9 2 1752 9 14 1752 4 33 1997 0 0 0 Sample Output November 15, 1997 is a Saturday January 1, 2000 is a Saturday July 4, 1998 is a Saturday February 11, 1732 is a Friday September 2, 1752 is a Wednesday September 14, 1752 is a Thursday 4/33/1997 is an invalid date.
The Umbrella Problem: 2054
Description "Forget it," Garret complained, throwing down the controller to his PlayStation VIII, "this level is impossible." He had just "died" for the 17th time on level 54 of the game "Lemmings 9: Lost in Space". "No it isn't," his brother Ferret replied, "and I can prove it." Ferret pulled his PlaySkool PDA from the back pocket of his Levi's Huggies. "First, picture the level as a rectangular grid." Ferret punched a few of the buttons on his PDA and a rectangle appeared as he described. "Your character, a Lemming holding an umbrella, starts at the top of this rectangle. His goal is to reach the bottom without dying." "I know that, you weasel, but what about the laser guns?" Garret whined. "The name is Ferret, and I was just getting to that. If we represent the level as a rectangular grid, then the Lemming can occupy one square and each laser gun can occupy a square. Remember the laser guns are cyclic: they all shoot up the first turn, right the second turn, down the third turn, left the fourth turn, and then repeat the sequence." "But you're forgetting the pits of lava!" Garret exclaimed. "You didn't let me finish. Each pit of lava also occupies a square. And each plot of grass, the Lemming's destination, can also occupy a square. Then, it's just a matter of manipulating the Lemming and laser beams in a series of turns to determine if it is possible for the Lemming to reach the bottom without 'dying'." "You think you're so smart, Ferret, let's see if you can explain that again in a clear, concise way." "Certainly": The level will consist of a grid of squares. The way each laser beam and the Lemming moves can be described in "turns". To determine if the Lemming can reach the bottom of the level without dying, Ferret devised some rules: Each turn will consist of two steps: First, the laser guns will "fire" and maintain until the end of the turn, a beam in a direction dependent on the number of the turn. On the first turn, each laser gun will shoot up (all squares directly above a laser gun are "unsafe" and cannot be occupied by the Lemming); on the second turn, each laser gun will shoot right; on the third turn, each laser gun will shoot down; on the fourth turn, each laser gun will shoot left; on the fifth turn, the sequence will repeat. Example: Column 01234 R 0| L |<- The Lemming will always start in a column on row 0 o 1| | In this example, on the first turn, the laser beam w 2| S | will occupy squares (3,0),(3,1); second turn, (4,2); 3| | third turn, (3,3),(3,4),(3,5),(3,6); fourth turn, 4| | (0,2),(1,2),(2,2); fifth turn (repeating), (3,0),(3,1), etc. 5| | (squares are represented using (column,row) notation) 6|GPPGG|<- The pits of lava and grass squares will always be in the last row Second, the Lemming will always move one row down, but to any one of three columns: one column to the left, one column to the right, or remain in the same column. In the above example, on the first turn the Lemming (L) could move to square (1,1), (2,1), or (3,1) (if he moved to (3,1), though, he would die because of the laser beam). However, on any turn the Lemming cannot move outside of the grid (i.e., he cannot move to column -1, or to a column number equal to the number of columns). The level is considered "possible" if the Lemming can reach any "grass" square without dying after a series of turns. The Lemming will die if at any point he occupies the same square as a laser gun, its beam, or a pit of lava. This includes: The Lemming moving into a square a pit of lava occupies, The Lemming moving into a square a laser gun occupies, The Lemming moving into a square a laser beam occupies (even if it is a grass square!), A laser gun firing a beam into a square the Lemming occupies Input Input to this problem will consist of a (non-empty) series of up to 100 data sets. Each data set will be formatted according to the following description, and there will be no blank lines separating data sets. Each data set will describe the starting conditions of the level. A single data set has the following components: Start line - A single line, "START x y", where 0 < x < 10 and x is the number of columns in the grid representing the level and 1 < y < 10 and y is the number of rows in the grid representing the level. The next y lines will represent the rows of the level, starting with row 0 (the top). Each line will consist of x letters. The letters will represent components of the level as follows: L - Lemming (there will only be one 'L' per data set, and it will always be in row 0) S - laser gun (these squares will never be in the final row) P - pit of lava (these squares will always be in the final row) G - grass (these squares will also always be in the final row) O - "empty" square of air End line -- A single line, "END". Following the final data set will be a single line, "ENDOFINPUT". Output Output for each data set will be exactly one line. The line will either be "FERRET" or "GARRET" (both all caps with no whitespace leading or following). "FERRET" will appear if the Lemming can make it safely (without dying) to any grass square at the bottom of the level after a series of turns. "GARRET" will be output for a data set if it fails to meet the criteria for a "FERRET" line.
Roman Order
Roman numerals are based on seven symbols: I = 1, V = 5, X = 10, L = 50, C = 100, D = 500 and M = 1000. Symbols are iterated to produce multiples of the decimal (1, 10, 100, 1,000) values, with V, L, D substituted for a multiple of five, and the iteration continuing: I "1", II "2", III "3", V "5", VI "6", VII "7", etc., and the same for other bases: X "10", XX "20", XXX "30", L "50", LXXX "80"; CC "200", DCC "700", etc. At the fourth iteration, a subtractive principle is employed, with the base placed before the higher base: IV for "4", IX for "9", XL for "40", XC for "90", CD for "400", CM for "900". The basic multiples of Roman numerals thus follow a pattern: ×1 ×2 ×3 ×4 ×5 ×6 ×7 ×8 ×9 Ones I II III IV V VI VII VIII IX Tens X XX XXX XL L LX LXX LXXX XC Hundreds C CC CCC CD D DC DCC DCCC CM Thousands M MM MMM A practical way to write a Roman number is to consider the modern Arabic numeral system, and separately convert the thousands, hundreds, tens, and ones as given in the chart above. So, for instance, 1234 may be thought of as "one thousand and two hundreds and three tens and four", obtaining M (one thousand) + CC (two hundreds) + XXX (thirty) + IV (four), for MCCXXXIV. Thus eleven is XI (ten and one), 29 is XXIX (twenty and nine), and 2011 is MMXI (two thousand and ten and one). Note that the subtractive principle is not extended beyond the chart: for example, IL is not used for 49, rather this should be written as forty (XL) and nine (IX), or XLIX. Given a list of numbers, you are to rearrange them so that if we write them as Roman numbers, they are in lexicographical order. Input There are multiple test cases. The first line of input is an integer T ≈ 100 indicating the number of test cases. Each test case starts with an integer 1 ≤ n ≤ 10000. Then n numbers 0 < ai < 4000. Output For each test case, output the n numbers in specified order. Sample Input 3 3 1 2 3 7 1 5 10 50 100 500 1000 11 4 5 6 7 8 9 10 11 12 13 14 Sample Output 1 2 3 100 500 1 50 1000 5 10 4 9 5 6 7 8 10 11 12 13 14
Java学习的正确打开方式

linux系列之常用运维命令整理笔录

Python十大装B语法
Python 是一种代表简单思想的语言，其语法相对简单，很容易上手。不过，如果就此小视 Python 语法的精妙和深邃，那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点，并附上详细的实例代码。如能在实战中融会贯通、灵活使用，必将使代码更为精炼、高效，同时也会极大提升代码B格，使之看上去更老练，读起来更优雅。

2019年11月中国大陆编程语言排行榜
2019年11月2日，我统计了某招聘网站，获得有效程序员招聘数据9万条。针对招聘信息，提取编程语言关键字，并统计如下： 编程语言比例 rank pl_ percentage 1 java 33.62% 2 cpp 16.42% 3 c_sharp 12.82% 4 javascript 12.31% 5 python 7.93% 6 go 7.25% 7 p...

《奇巧淫技》系列-python！！每天早上八点自动发送天气预报邮件到QQ邮箱

SQL-小白最佳入门sql查询一

Nginx 原理和架构
Nginx 是一个免费的，开源的，高性能的 HTTP 服务器和反向代理，以及 IMAP / POP3 代理服务器。Nginx 以其高性能，稳定性，丰富的功能，简单的配置和低资源消耗而闻名。 Nginx 的整体架构 Nginx 里有一个 master 进程和多个 worker 进程。master 进程并不处理网络请求，主要负责调度工作进程：加载配置、启动工作进程及非停升级。worker 进程负责处...
【图解经典算法题】如何用一行代码解决约瑟夫环问题

“狗屁不通文章生成器”登顶GitHub热榜，分分钟写出万字形式主义大作

《程序人生》系列-这个程序员只用了20行代码就拿了冠军

11月8日，由中国信息通信研究院、中国通信标准化协会、中国互联网协会、可信区块链推进计划联合主办，科技行者协办的2019可信区块链峰会将在北京悠唐皇冠假日酒店开幕。 　　区块链技术被认为是继蒸汽机、电力、互联网之后，下一代颠覆性的核心技术。如果说蒸汽机释放了人类的生产力，电力解决了人类基本的生活需求，互联网彻底改变了信息传递的方式，区块链作为构造信任的技术有重要的价值。 　　1...
Python 植物大战僵尸代码实现(2):植物卡片选择和种植

Java世界最常用的工具类库
Apache Commons Apache Commons有很多子项目 Google Guava 参考博客

【技巧总结】位运算装逼指南

8年经验面试官详解 Java 面试秘诀

1.两种思维方式在求职面试中，经常会考察这种问题：北京有多少量特斯拉汽车？某胡同口的煎饼摊一年能卖出多少个煎饼？深圳有多少个产品经理？一辆公交车里能装下多少个乒乓球？一个正常成年人有多少根头发？这类估算问题，被称为费米问题，是以科学家费米命名的。为什么面试会问这种问题呢？这类问题能把两类人清楚地区分出来。一类是具有文科思维的人，擅长赞叹和模糊想象，它主要依靠的是人的第一反应和直觉，比如小孩...
17张图带你解析红黑树的原理！保证你能看懂！

so easy！ 10行代码写个"狗屁不通"文章生成器

MySQL数据库总结