昨晚舉辦了516寢室的第五場競賽,題目很水,但也很基礎,題目網址https://cn.vjudge.net/contest/217247#problem/A 密碼 516... 下面直接上題:
第一題很水,看第二題
123 -234.00Sample Output
123.00 234.00
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
double a,b,c,d,e;
while(~scanf("%lf",&a))
{
if(a<0)b=-a;
else b=a;
printf("%.2lf\n",b);
}
}
In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + ... + n.
OutputFor each case, output SUM(n) in one line, followed by a blank line. You may assume the result will be in the range of 32-bit signed integer.
Sample Input
1 100Sample Output
1 5050
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ll a,b,c,d,e;
while(~scanf("%lld",&a))
{
b=0;
for(int i=1;i<=a;i++)
{
b+=i;
}
printf("%lld\n",b);
printf("\n");
}
}
E題
Give you a letter x and a number y , you should output the result of y+f(x).
6 R 1 P 2 G 3 r 1 p 2 g 3Sample Output
19 18 10 -17 -14 -4
using namespace std;
typedef long long ll;
int main()
{
ll a,c,d,e,f;
char b;
scanf("%lld",&a);
while(a>0)
{ getchar();
b=getchar();
scanf("%lld",&c);
if(b>=97)printf("%lld\n",96-b+c);
else printf("%lld\n",b-64+c);
a--;
}
}
F題
OutputOutput the condition of the n-th lamp after infinity operations ( 0 - off, 1 - on ).Sample Input
1 5Sample Output
1 0 Consider the second test case: The initial condition : 0 0 0 0 0 … After the first operation : 1 1 1 1 1 … After the second operation : 1 0 1 0 1 … After the third operation : 1 0 0 0 1 … After the fourth operation : 1 0 0 1 1 … After the fifth operation : 1 0 0 1 0 … The later operations cannot change the condition of the fifth lamp any more. So the answer is 0.Hint
hint
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ll a,b,c;
while(~scanf("%lld",&a))
{
b=0;
for(int i=1;i<=a;i++)
if(a%i==0)b++;
c=b%2;
printf("%lld\n",c);
}
}
F題重點在思路!!!!一定要仔細看
G題
首先,我們就要設置一個安全的密碼。那什麼樣的密碼才叫安全的呢?一般來說一個比較安全的密碼至少應該滿足下面兩個條件:
(1).密碼長度大於等於8,且不要超過16。
(2).密碼中的字符應該來自下面“字符類別”中四組中的至少三組。
這四個字符類別分別爲:
1.大寫字母:A,B,C...Z;
2.小寫字母:a,b,c...z;
3.數字:0,1,2...9;
4.特殊符號:~,!,@,#,$,%,^;
給你一個密碼,你的任務就是判斷它是不是一個安全的密碼。
3 a1b2c3d4 Linle@ACM ^~^@^@!%Sample Output
NO YES NO
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ll a,b,c,d,e,f,l;
l=0;
char s[51];
scanf("%lld",&a);
getchar();
for(int i=0;i<a;i++)
{ b=0;c=0;d=0;e=0;
gets(s);
l=strlen(s);
if(l<8||l>16) printf("NO\n");
else{
for(int i=0;i<l;i++)
{
if(s[i]<=122&&s[i]>=97)b=1;
if(s[i]<=90&&s[i]>=65)c=1;
if(s[i]<=57&&s[i]>=48)d=1;
if(s[i]=='~'||s[i]=='!'||s[i]=='@'||s[i]=='#'||s[i]=='$'||s[i]=='%'||s[i]=='^')e=1;
}
if(b+c+d+e>=3)printf("YES\n");
else printf("NO\n");
}
}
}
H題
1 2 3Sample Output
1 10 11
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
int a[100];
ll n;
while(~scanf("%lld",&n))
{
int i=0;
a[i]=n%2;
n=n/2;
while(n)
{
i++;
a[i]=n%2;
n=n/2;
}
for(int j=i;j>=0;j--)
printf("%d",a[j]);
printf("\n");
}
}
I題
after each case, you should a blank line.Sample Input
3 2Sample Output
+---+ | | | | +---+
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ll a,b,c,d,e;
while(~scanf("%lld %lld",&a,&b))
{
printf("+");
for(int i=0;i<a;i++)
printf("-");
printf("+\n");
for(int j=0;j<b;j++)
{
printf("|");
for(int i=0;i<a;i++)
printf(" ");
printf("|\n");
}
printf("+");
for(int i=0;i<a;i++)
printf("-");
printf("+\n");
printf("\n");
}
}
總的來說,題目都很水,重點在提高基礎能力。