Arab Collegiate Programming Contest 2012 J- Math Homework
思路:由于只有1-6这几个数,而这几个数的最小公倍数是60,所以只需要求出60以内有多少满足条件的数即可。
再就是求出对于给定的n,求出60的倍数。然后就是怎样求的问题了。
首先可以写成如下形式:
10n-40=60*n (把最后的40个数去掉,最后在求结果的时候再加上)
n=(10n-40)/60. (结果一定可以整除)
代码如下:
#include<cstdio>
#define ll long long
#define mod 1000000007
ll pw(ll a,ll b)
{
ll ans=;
while(b){
if(b&) ans=ans*a%mod;
b>>=;
a=a*a%mod;
}
return ans;
}
int main()
{
int i,j,t;
ll n;
char str[];
bool f[];
scanf("%d",&t);
while(t--){
scanf("%I64d %s",&n,str);
for(i=;i<;i++){
f[i]=;
for(j=;j<;j++){
if(str[j]==''&&i%(j+)==) f[i]=;
else if(str[j]==''&&i%(j+)!=) f[i]=;
}
}
int c=;
if(n==){
for(i=;i<=;i++) c+=f[i];
printf("%d\n",c);
continue;
}
for(i=;i<;i++) c+=f[i];
ll p=pw(,n);
ll ans=(p-+mod)%mod*pw(,mod-)%mod;
ans=ans*c%mod;
for(i=;i<;i++) ans+=f[i];
printf("%I64d\n",ans);
}
return ;
}
Arab Collegiate Programming Contest 2012 J- Math Homework的更多相关文章
- 2018 Arab Collegiate Programming Contest (ACPC 2018) E - Exciting Menus AC自动机
E - Exciting Menus 建个AC自动机求个fail指针就好啦. #include<bits/stdc++.h> #define LL long long #define fi ...
- 2018 Arab Collegiate Programming Contest (ACPC 2018) G. Greatest Chicken Dish (线段树+GCD)
题目链接:https://codeforces.com/gym/101991/problem/G 题意:给出 n 个数,q 次询问区间[ li,ri ]之间有多少个 GCD = di 的连续子区间. ...
- 2018 Arab Collegiate Programming Contest (ACPC 2018) H - Hawawshi Decryption 数学 + BSGS
H - Hawawshi Decryption 对于一个给定的生成数列 R[ 0 ] 已知, (R[ i - 1 ] * a + b) % p = R[ i ] (p 是 质数), 求最小的 x 使得 ...
- Gym 100952E&&2015 HIAST Collegiate Programming Contest E. Arrange Teams【DFS+剪枝】
E. Arrange Teams time limit per test:2 seconds memory limit per test:64 megabytes input:standard inp ...
- The Ninth Hunan Collegiate Programming Contest (2013) Problem J
Problem J Joking with Fermat's Last Theorem Fermat's Last Theorem: no three positive integers a, b, ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Capture the Flag
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5503 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Team Formation
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5494 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Lunch Time
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5499 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Convert QWERTY to Dvorak
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5502 The 12th Zhejiang Provincial ...
随机推荐
- Chrome浏览器任意修改网页内容
在Chrome浏览器按F12,打开开发者工具,切换到console选项卡: 在下面的输入行输入下面的命令回车: document.body.contentEditable="true&quo ...
- $.when()方法翻译2
mac不知道为何,文章字数一多,浏览器就重启.只好分开写了. In the event a Deferred was resolved with no value, the corresponding ...
- BZOJ 3958 Mummy Madness
Problem BZOJ Solution 算法:二分+扫描线 快要2019年了,就瞎写一篇博客来凑数,不然感觉太荒凉了-- 答案是可二分的,那么二分的依据是什么呢?不妨设当前二分的答案为\(mid\ ...
- 2017-2018 ACM-ICPC, NEERC, Southern Subregional Contest, qualification stage
2017-2018 ACM-ICPC, NEERC, Southern Subregional Contest, qualification stage A. Union of Doubly Link ...
- 调用HTMLTestRunner生产的报告内容为空解决办法
开始代码如下,生成报告内容为空: #coding=utf-8 import unittest,time,reimport requestsimport jsonimport HTMLTestRunne ...
- 使用FormData数据做图片上传: new FormData() canvas实现图片压缩
使用FormData数据做图片上传: new FormData() canvas实现图片压缩 ps: 千万要使用append不要用set 苹果ios有兼容问题导致数据获取不到,需要后台 ...
- UFT12.续期的操作方法
安装完毕UFT后,页面中报install错误,此时报此错误的原因是因为UFT的许可证过期了,解决方法如下: 方法是找到C:\ProgramData目录下的SafeNet Sentinel文件夹将其删除 ...
- Oracle数据库(64位) 及 PLSQL(64位)的组合安装【第一篇】
目前PC端普遍使用64位操作系统,64位操作系统在性能上比32位更佳,但是兼容性上则不如32的操作系统,Oracle提供了64和32两种版本,而PLsql工具则只有32位,在这篇文章详细的讲述了如何在 ...
- linux下redis的安装与部署
一.Redis介绍 Redis是当前比较热门的NOSQL系统之一,它是一个key-value存储系统.和Memcache类似,但很大程度补偿了Memcache的不足,它支持存储的value类型相对更多 ...
- nginx配置tomcat集群
显示nginx的核心配置 #user nobody;worker_processes 1; events { worker_connections 1024; #并发连接数} http { in ...