没想到今天也有...
1.
print("Hello excellent athletes!")
print("Hello excellent acmers!")
print("Welcome to HZNU!")
2.
while True:
try:
a = list(input().split())
s1 = a[0]
s2 = a[1]
cnt = int(a[2])
for i in range(cnt):
print(s2[i], end="")
print(s1, end="")
for i in range(cnt, len(s2)):
print(s2[i], end="")
print("")
except:
break
3. c代码,抄的以前的
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define R 10000
int main()
{
char str1[R], *p;
int i = 0;
memset(str1, 0, sizeof(str1));
while (gets(str1) != '\0') {
p = str1;
for (i = 1; i <= strlen(str1); i++) {
if (*p != *(p + 1))
printf("%c", *p);
p++;
}
printf("\n");
}
return 0;
}
4.同上
#include <stdio.h>
#include <string.h>
int main()
{
int T,i,j;
scanf("%d",&T);
getchar();
char arr[10000];
for (i=0;i<T;i++)
{
int ret=0;
scanf("%s",arr);
int len=strlen(arr);
for (j=0;j<len;j++)
{
if (arr[j]=='a' || arr[j]== 'e' || arr[j]=='i' || arr[j]=='o' || arr[j]=='u')
{
ret++;
}
}
printf("%d\n",ret);
}
return 0;
}
5.
n=eval(input())
for i in range(n):
meter=eval(input())
walk=meter/1.2
bike=27+23+meter/3.0
if walk==bike:
print("All")
elif walk>bike:
print("Bike")
else:
print("Walk")
6.
t=eval(input())
for j in range(t):
n,k,m=map(int,input().split())
all_fish=list(map(int,input().split()))
all_fish.sort()
sum=0
for i in range(k):
sum+=all_fish[i]
if sum<=n:
print(0)
else:
print(sum-n)
7.可以dfs 但没必要
while True:
try:
n=eval(input())
q=n-265716
for i in range(9):
print(9+q%3,end=" ")
q //= 3
print(9+q%3)
except:
break
8.Wythoff博弈模型,两个人如果都采用正确操作,那么面对非奇异局势,先拿者必胜;反之,则后拿者取胜. 局势(N,M)(N<M)满足:N==(int)((1.0+sqrt(5.0))/2.0*(M-N))时,该局势为奇异局势,后拿者必胜.
(这道题建议拿c++写吧,py算术很麻烦)
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int a, b;
while(scanf("%d %d", &a,&b) != EOF )
{
if( a > b )
swap(a, b);
int tmp = (int) ((1.0 + sqrt(5.0)) / 2.0 * (b - a)); // 奇异局势
if( a == tmp )
cout << 0 << endl;
else
cout << 1 << endl;
}
return 0;
}