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 Description
F(x,m) 代表一个全是由数字x组成的m位数字。请计算,以下式子是否成立:

F(x,m) mod k ≡ c

 
Input
第一行一个整数T,表示T组数据。
每组测试数据占一行,包含四个数字x,m,k,c

1≤x≤9

1≤m≤1010

0≤c<k≤10,000

 
Output
对于每组数据,输出两行:
第一行输出:"Case #i:"。i代表第i组测试数据。
第二行输出“Yes” 或者 “No”,代表四个数字,是否能够满足题目中给的公式。
 
Sample Input
3
1 3 5 2
1 3 5 1
3 5 99 69
 
Sample Output
Case #1:
No
Case #2:
Yes
Case #3:
Yes

Hint

对于第一组测试数据:111 mod 5 = 1,公式不成立,所以答案是”No”,而第二组测试数据中满足如上公式,所以答案是 “Yes”。

 
Source
 
没弄数学专题结果百度之星被这题卡了。。
(a/b)%mod = (a)%(b*mod)/b%mod 懂了这个完全就是水题。
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std;
typedef long long LL; LL pow_mod(LL a,LL n,LL mod){
LL ans = ;
while(n){
if(n&) ans = ans*a%mod;
a = a*a%mod;
n>>=;
}
return ans;
} int main()
{
LL x,m,k,c;
int tcase;
scanf("%d",&tcase);
int t =;
while(tcase--){
cin>>x>>m>>k>>c;
printf("Case #%d:\n",t++);
LL mod = *k;
LL ans = ((pow_mod(,m,mod)-)*x%mod+mod)%mod;
if(ans==*c%mod){
printf("Yes\n");
}else printf("No\n");
}
return ;
}

最新文章

  1. [MySQL Reference Manual] 5 MySQL 服务管理
  2. The Monty Hall Problem
  3. mysql 时间函数
  4. 为什么玩VR眼镜会头晕?
  5. microsoft .netframework Available Source Code Components
  6. [iOS UI进阶 - 4.0] 涂鸦app Demo
  7. ASP.NET MVC(三) TypeScript
  8. [转]Python中的矩阵转置
  9. android中的返回键与Activity
  10. eclipse中JPA插件的安装与使用
  11. git常见使用场景总结
  12. 20165313 《Java程序设计》第一周学习总结
  13. solr开发从查询结果集中获取对象数据
  14. 基于jquery下拉列表树插件代码
  15. BZOJ1297: [SCOI2009]迷路 矩阵快速幂
  16. Sentinel-dashboard
  17. PHP 5.6.32 增加pdo_dblib.so拓展
  18. Difference between Netbios and Host name
  19. TDS协议解析
  20. 多线程-信号量Semaphore

热门文章

  1. Markdown中如何添加特殊符号
  2. 服务器TIME_WAIT和CLOSE_WAIT分析和解决办法
  3. nginx静态资源web服务
  4. 关于缺失值NaN
  5. 如何把list当成栈或者队列来用
  6. POJ - 3660 Cow Contest(传递闭包)
  7. javascript常见数据集
  8. windows系统使用的误区
  9. 使用PYTHON创建XML文档_python
  10. [Offer收割]编程练习赛50