2013 ACM/ICPC Asia Regional Online —— Warmup2 兩個水題
A Computer Graphics Problem
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 150 Accepted Submission(s): 128
Problem Description
In this problem we talk about the study of Computer Graphics. Of course, this is very, very hard.
We have designed a new mobile phone, your task is to write a interface to display battery powers.
Here we use '.' as empty grids.
When the battery is empty, the interface will look like this:
When the battery is 60% full, the interface will look like this:
Each line there are 14 characters.
Given the battery power the mobile phone left, say x%, your task is to output the corresponding interface. Here x will always be a multiple of 10, and never exceeds 100.
We have designed a new mobile phone, your task is to write a interface to display battery powers.
Here we use '.' as empty grids.
When the battery is empty, the interface will look like this:
*------------* |............| |............| |............| |............| |............| |............| |............| |............| |............| |............| *------------*
When the battery is 60% full, the interface will look like this:
*------------* |............| |............| |............| |............| |------------| |------------| |------------| |------------| |------------| |------------| *------------*
Each line there are 14 characters.
Given the battery power the mobile phone left, say x%, your task is to output the corresponding interface. Here x will always be a multiple of 10, and never exceeds 100.
Input
The first line has a number T (T < 10) , indicating the number of test cases.
For each test case there is a single line with a number x. (0 < x < 100, x is a multiple of 10)
For each test case there is a single line with a number x. (0 < x < 100, x is a multiple of 10)
Output
For test case X, output "Case #X:" at the first line. Then output the corresponding interface.
See sample output for more details.
See sample output for more details.
Sample Input
2
0
60
Sample Output
Case #1:
*------------*
|............|
|............|
|............|
|............|
|............|
|............|
|............|
|............|
|............|
|............|
*------------*
Case #2:
*------------*
|............|
|............|
|............|
|............|
|------------|
|------------|
|------------|
|------------|
|------------|
|------------|
*------------*
Source
直接看樣例,有點像電量顯示的東西,直接輸出。
AC程式碼:
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<cstdio>
using namespace std;
void show(int p)
{
int i;
cout<<"*------------*"<<endl;
p=10-p;
for(i=0;i<p;i++)
cout<<"|............|"<<endl;
p=10-p;
for(i=0;i<p;i++)
cout<<"|------------|"<<endl;
cout<<"*------------*"<<endl;
}
int main()
{
int tes,p;
scanf("%d",&tes);
int cas=0;
while(tes--)
{
scanf("%d",&p);
p/=10;
printf("Case #%d:\n",++cas);
show(p);
}
return 0;
}
//0MS 272K
The Number Off of FFF
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 289 Accepted Submission(s): 136
Problem Description
X soldiers from the famous "*FFF* army" is standing in a line, from left to right.
You, as the captain of *FFF*, decides to have a "number off", that is, each soldier, from left to right, calls out a number. The first soldier should call "One", each other soldier should call the number next to the number called out by the soldier on his left side. If every soldier has done it right, they will call out the numbers from 1 to X, one by one, from left to right.
Now we have a continuous part from the original line. There are N soldiers in the part. So in another word, we have the soldiers whose id are between A and A+N-1 (1 <= A <= A+N-1 <= X). However, we don't know the exactly value of A, but we are sure the soldiers stands continuously in the original line, from left to right.
We are sure among those N soldiers, exactly one soldier has made a mistake. Your task is to find that soldier.
You, as the captain of *FFF*, decides to have a "number off", that is, each soldier, from left to right, calls out a number. The first soldier should call "One", each other soldier should call the number next to the number called out by the soldier on his left side. If every soldier has done it right, they will call out the numbers from 1 to X, one by one, from left to right.
Now we have a continuous part from the original line. There are N soldiers in the part. So in another word, we have the soldiers whose id are between A and A+N-1 (1 <= A <= A+N-1 <= X). However, we don't know the exactly value of A, but we are sure the soldiers stands continuously in the original line, from left to right.
We are sure among those N soldiers, exactly one soldier has made a mistake. Your task is to find that soldier.
Input
The rst line has a number T (T <= 10) , indicating the number of test cases.
For each test case there are two lines. First line has the number N, and the second line has N numbers, as described above. (3 <= N <= 105)
It guaranteed that there is exactly one soldier who has made the mistake.
For each test case there are two lines. First line has the number N, and the second line has N numbers, as described above. (3 <= N <= 105)
It guaranteed that there is exactly one soldier who has made the mistake.
Output
For test case X, output in the form of "Case #X: L", L here means the position of soldier among the N soldiers counted from left to right based on 1.
Sample Input
2
3
1 2 4
3
1001 1002 1004
Sample Output
Case #1: 3
Case #2: 3
Source
解題思路:解決辦法就是用a[i]-i看差值,我想的是肯定全部都一樣,有一個除外,那個不一樣的就是出錯的,但是WA了,最後吉吉提醒可能有1 2 3這樣的情況。這樣誰錯了?毫無疑問,這樣的話,只能是1出錯了。
AC程式碼:
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[1000005];
int main()
{
int tes,n,i,p;
scanf("%d",&tes);
int cas=0;
while(tes--)
{
scanf("%d",&n);
for(i=1; i<=n; i++)
scanf("%d",&a[i]);
for(i=1; i<=n; i++)
{
a[i]=a[i]-i;
}
int flag=0;
for(i=1; i<n; i++)
if(a[i]!=a[i+1])
{
flag=1;
break;
}
if(!flag) //沒有一個出錯,全部差值都一樣,一號錯
p=1;
else
{
if(a[1]!=a[2]&&a[1]!=a[3]) //a[1]不同
p=1;
if(a[2]!=a[1]&&a[2]!=a[3]) //a[2]不同
p=2;
for(i=3; i<=n; i++)
if(a[i]!=a[i-1]&&a[i]!=a[i-2]) //a[i]不同
{
p=i;
break;
}
}
printf("Case #%d: %d\n",++cas,p);
}
return 0;
}
/*
23
3
1 2 4
3
1001 1002 1004
3
1 3 4
3
1 5 6
3
2 3 3
3
1 2 3
*/
//78MS 632K
相關文章
- 2017 ACM/ICPC Asia Regional Shenyang Online - 做題記錄ACM
- HDU4998 Rotate (2014 ACM/ICPC Asia Regional Anshan Online)ACM
- 2015 ACM/ICPC Asia Regional Shenyang Online-1012 Largest PointACM
- HDU5023A Corrupt Mayor's Performance Art (2014 ACM/ICPC Asia Regional Guangzhou Online)ORMACM
- The 2021 ICPC Asia Shenyang Regional Contest
- 2016-2017 ACM-ICPC Asia-Bangkok Regional ContestACM
- HDU 5052 Yaoge’s maximum profit 光禿禿的樹鏈拆分 2014 ACM/ICPC Asia Regional Shanghai Online...ACMAI
- 2018-2019 ACM-ICPC, Asia Seoul Regional Contest——A - CircuitsACMUI
- The 2024 ICPC Asia Nanjing Regional ContestNaN
- The 2022 ICPC Asia Xian Regional Contest 前六題
- The 2022 ICPC Asia Nanjing Regional ContestNaN
- The 2023 ICPC Asia Macau Regional ContestMac
- The 2022 ICPC Asia Xian Regional Contest
- The 2022 ICPC Asia Hangzhou Regional Programming Contest
- The 2023 ICPC Asia EC Regionals Online Contest (I)
- The 2024 ICPC Asia East Continent Online Contest (I)AST
- The 2022 ICPC Asia Nanjing Regional Contest IGDA,和令人疑惑的MNaN
- The 2023 ICPC Asia Hangzhou Regional Contest (The 2nd Universal Cup. Stage 22: Hangzhou)
- 2017-2018 ACM-ICPC Southeast Regional Contest (Div. 1)ACMAST
- The 2023 ICPC Asia Jinan Regional Contest (The 2nd Universal Cup. Stage 17: Jinan)補題記錄NaN
- 2017-2018 ACM-ICPC Pacific Northwest Regional Contest (Div. 1)ACM
- 2017-2018 ACM-ICPC, Central Europe Regional Contest (CERC 17)ACM
- Chayas - 2023-2024 ICPC, Asia Yokohama Regional Contest 2023, Problem E
- The 2024 ICPC Asia EC Regionals Online Contest (II) - Problem B. Mountain BookingAI
- The 2024 ICPC Asia EC Regionals Online Contest (II) - Problem H. Points Selection
- 2017-2018 ACM-ICPC Southwestern European Regional Programming Contest (SWERC 2017)ACM
- 2016-2017 ACM-ICPC Northwestern European Regional Programming Contest (NWERC 2016)ACM
- 2016-2017 ACM-ICPC Southwestern European Regional Programming Contest (SWERC 2016)ACM
- ACM ICPC Vietnam National Second RoundACM
- ACM 噴水裝置(二)ACM
- ACM 噴水裝置(一)ACM
- HDU4091(2011 Asia Shanghai Regional Contest)AI
- acm/icpc入門級演算法模板ACM演算法
- ACM HDU 1279 驗證角谷猜想(簡單水題)ACM
- 2015 ACM/ICPC EC-FinalACM
- 2013成都網路賽 兩個簡單題
- HDU4592 Boring Game (2013 ACM-ICPC南京賽區全國邀請賽) 高斯消元GAMACM
- 2024 ICPC Online 第二場(K)