codeup26756 bit number problem

Source: Internet
Author: User
codeup26756 bit number problem

Time limit 1000MS/128MB
The title describes How many of the numbers in the N-digit number have an even number 3.  Since the result can be very large, you only need to output this answer to 12345 of the value of the remainder. input read into a number n output

The number of outputs has an even number of numbers 3. Sample Input

2
Sample output
73
hint 1<=n<=1000


Code

#include <iostream>
using namespace std;
const int N = 1005;
int a[n][2];

int main () {
	int n,k=9;
	cin>>n;
	a[1][0]=9; A[1][1]=1;
	A[I][0] I-digit an even number of 3    a[i][1] I in the number of odd number 3 for
	(int i=2; i<=n; i++) {
		if (i==n) k--;	The first digit cannot be 0 
		a[i][0]= (k*a[i-1][0]+a[i-1][1])%12345;
		A[i][1]= (a[i-1][0]+k*a[i-1][1])%12345;
	}
	cout<<a[n][0]<<endl;
	return 0;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.