- 目录
- P8377 [PFOI Round1] 暴龙的火锅
- 题目思路
- 题目代码
- P8410 「SvR-1」Don't Mozheng. /oh
- 题目思路
- 题目代码
题目代码仅为JAVA练习,因此有超时测试点
import java.util.*;
public class Main {
public static void main(String[]args)
{
Scanner input = new Scanner(System.in);
int[] a = new int[1000015];
int t,n;
a[1]=a[2]=1;
for(int i=3;i<=1000010;i++) {
a[i]=(a[i-1]+a[i-2])%9;
}
for(int i=1;i<=1000010;i++) {
a[i]=(a[i-1]+a[i])%9;
}
t = input.nextInt();
while(t!=0) {
n= input.nextInt();
System.out.printf("%dn",a[n]);
t--;
}
}
}
P8410 「SvR-1」Don’t Mozheng. /oh
题目思路
模拟
题目代码import java.util.*;
public class Main {
public static void main(String[]args)
{
int n=0,a=0,b=0;
int sum=0;
String str1,str2;
str1 = new String();
str2 = new String();
Scanner input=new Scanner(System.in);
n=input.nextInt();
a=input.nextInt();
b=input.nextInt();
str1 = input.nextLine();
//System.out.printf("%d %dn",a,b);
while(n!=0) {
str1=input.nextLine();
str2=input.nextLine();
if(str2.equals("/oh")) {
sum+=a;
}
if(str2.equals("/hsh")) {
sum+=b;
}
n--;
//System.out.printf("%dn",str2.length());
}
System.out.printf("%dn",sum);
}
}



