栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

入坑JAVA(二)

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

入坑JAVA(二)

入坑JAVA(二)
  • 目录
    • P8377 [PFOI Round1] 暴龙的火锅
      • 题目思路
      • 题目代码
    • P8410 「SvR-1」Don't Mozheng. /oh
      • 题目思路
      • 题目代码

目录 P8377 [PFOI Round1] 暴龙的火锅 题目思路

仅为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);
	}
}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/988842.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号