7-1 Plan (15 分)

本文介绍了一个基于历史考试数据预测未来考试科目的算法。通过分析已知的考试科目规律,可以为学生提供有效的复习计划,以应对不确定的考试安排。特别地,文章详细描述了一个Java程序,该程序能够计算在特定学期中所有可能的考试科目组合。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

7-1 Plan (15 分)

******* Institute of Technology is the highest academic institution in *******, so it has extremely strict discipline. In order to get a good grades, Li had to prepare a review route in advance to cope with the fianl exam. There are n liberal arts exams in this semester, and there are 4 exam subjects, namely politics, history, geography and comprehensive course . Every time you take a test but it is uncertain, so Li don’t know which course to review before the exam. He hopes to predict the exams that may be tested next time. So he collected information in previous liberal arts exams. From the previous exams, he discovered several rules:

  1. If the test is political, then the next time you will test the history;
  2. If the test is comprehensive course, then the next time you will test the geography;
  3. If the test is history, then the next time you will take politics or geography;
  4. If the test is geography, then the next time you either take history or the comprensive course.

Li already knows that the first exam in this semester is political. He intends to develop an exam review plan that can address all possible situations. Therefore, he would like to know how many possible test subjects are arranged throughout the semester to meet the above rules.

输入格式:

A positive integer n represents the total number of exams for the semester. The input data is guaranteed to be n<=10000.

输出格式:

A positive integer indicating the total number of subject arrangements for the rule. Considering that this result can be very large, you only need to output the value of mod 7654321.

输入样例:

5

输出样例:

5

import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner hl=new Scanner(System.in);
		int N=hl.nextInt();
			System.out.println((long)f(N));
	}
	
	static double  f(int n) {
		
		if(n==1 || n==2) {
			return 1;
		}
		
		double num = 0,numa,numb;
		numa=numb=1.0;
		
		for(int k=3;k<=n;k++){
			num=(numa+numb)%7654321;
			numb=numa;
			numa=num%7654321;
		}
		return num;
	}

}
vae@vae-ASUS-TUF-Gaming-A15-FA507UU-FA507UU:~$ roscd log vae@vae-ASUS-TUF-Gaming-A15-FA507UU-FA507UU:~/.ros/log/f34d8a2e-6054-11f0-9921-77d90da18a94$ ls -lt 总用量 7928 -rw-rw-r-- 1 vae vae 140199 714 15:43 roslaunch-vae-ASUS-TUF-Gaming-A15-FA507UU-FA507UU-15887.log -rw-rw-r-- 1 vae vae 5728053 714 15:43 master.log -rw-rw-r-- 1 vae vae 518 714 15:43 rviz-3-stdout.log -rw-rw-r-- 1 vae vae 35139 714 15:40 rosout.log -rw-rw-r-- 1 vae vae 140455 714 15:35 roslaunch-vae-ASUS-TUF-Gaming-A15-FA507UU-FA507UU-15513.log -rw-rw-r-- 1 vae vae 140854 714 15:12 roslaunch-vae-ASUS-TUF-Gaming-A15-FA507UU-FA507UU-14643.log -rw-rw-r-- 1 vae vae 140854 714 15:04 roslaunch-vae-ASUS-TUF-Gaming-A15-FA507UU-FA507UU-14057.log -rw-rw-r-- 1 vae vae 798209 714 11:16 roslaunch-vae-ASUS-TUF-Gaming-A15-FA507UU-FA507UU-11716.log -rw-rw-r-- 1 vae vae 798209 714 10:35 roslaunch-vae-ASUS-TUF-Gaming-A15-FA507UU-FA507UU-10896.log -rw-rw-r-- 1 vae vae 143846 714 09:57 roslaunch-vae-ASUS-TUF-Gaming-A15-FA507UU-FA507UU-10193.log -rw-rw-r-- 1 vae vae 149 714 09:50 rosout-1-stdout.log -rw-rw-r-- 1 vae vae 14198 714 09:50 roslaunch-vae-ASUS-TUF-Gaming-A15-FA507UU-FA507UU-9995.log vae@vae-ASUS-TUF-Gaming-A15-FA507UU-FA507UU:~/.ros/log/f34d8a2e-6054-11f0-9921-77d90da18a94$ cd /home/vae/.ros/log/roslaunch-vae-ASUS-TUF-Gaming-A15-FA507UU-FA507UU-15887.log bash: cd: /home/vae/.ros/log/roslaunch-vae-ASUS-TUF-Gaming-A15-FA507UU-FA507UU-15887.log: 没有那个文件或目录 结合上面问题
最新发布
07-15
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值