Hdu 5690 (modulo operation)

Source: Internet
Author: User

All X

Time limit:2000/1000 MS (java/others) Memory limit:65536/65536 K (java/others)
Total submission (s): 1076 Accepted Submission (s): 510


Problem DescriptionF(x,m) Representing a whole is made up of numbersxComposed ofmBit number. Please calculate whether the following formula is true:

F(X,M) o k ≡ < Span id= "mathjax-span-32" class= "Mi" style= "font-family:mathjax_math; Font-style:italic; " >c

Input first line an integerTSaidTGroup data.
One row for each set of test data, containing four digitsx,m,k,c

1≤x≤9

1≤m≤ten

0 c<k10,000

Output outputs two lines for each set of data:
The first line of output: "Case #i:".IOn behalf of sectionGroup i test data.
The second line output "Yes" or "No", representing four numbers, whether it can satisfy the formula given in the topic.

Sample Input31 3 5 21 3 5 13 5 99 69

Sample outputcase #1: nocase #2: yescase #3: Yes HintFor the first set of test data: 111 MoD 5 = 1, the formula is not true, so the answer is "no", and the second set of test data satisfies the above formula, so the answer is "yes".

Source 2016 "Baidu Star"-The Preliminary Round (Astar round2a) did not get math special results Baidu Star was the problem card. (A/b)%mod = (a)% (B*mod)/b%mod Understand this is a water problem entirely.
#include <stdio.h>#include<string.h>#include<algorithm>#include<iostream>#include<stdlib.h>#include<math.h>using namespaceStd;typedefLong LongLL; ll Pow_mod (ll a,ll n,ll MoD) {ll ans=1;  while(n) {if(n&1) ans = ans*a%MoD; A= a*a%MoD; N>>=1; }    returnans;}intMain () {LL x,m,k,c; inttcase; scanf ("%d",&tcase); intt =1;  while(tcase--) {cin>>x>>m>>k>>C; printf ("Case #%d:\n", t++); LL MoD=9*K; LL ans= ((Pow_mod (Ten, M,mod)-1) *x%mod+mod)%MoD; if(ans==9*c%MoD) {printf ("yes\n"); }Elseprintf"no\n"); }    return 0;}

Hdu 5690 (modulo operation)

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.