偶数个3

偶数个3

时间限制: 1000 ms  |  内存限制: 65535 KB
难度: 1
描述

在所有的N位数中,有多少个数中有偶数个数字3?

 

输入
第一行为一个整数T,代表有T组数据。(T<10000)
接下来T行,每行一个正整数N。(1<=N<=1000)
输出
每行输出一个整数,即方案数(由于结果可能很大,你只需要输出这个答案mod 12345的值。)。
样例输入
1
2
样例输出
73

import java.util.Scanner;

public class Main {

	static int arr[] = new int[10005];
	static int temp[] = new int[10005];

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int times = scanner.nextInt();
		while (times-- != 0) {
			int number = scanner.nextInt();
			arr[1] = 8;
			arr[2] = 73;
			temp[1] = 1;
			for (int i = 2; i <= number; i++) {
				temp[i] = (9 * temp[i - 1] + arr[i - 1]) % 12345;
			}
			for (int i = 3; i <= number; i++) {
				arr[i] = (temp[i - 1] + 9 * arr[i - 1]) % 12345;
			}
			System.out.println(arr[number]);
		}
	}

}


  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值