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 ...
随机推荐
- javascript经典小游戏代码集合
http://www.jb51.net/Special/349.htm
- 前端bootstrap框架禁用响应式的方法
在Bootstrap中极其重要的一个技术内容便是响应式布局了,一次编码针对不同设备终端的强大能力使得响应式技术愈发流行. 不过正所谓“萝卜青菜各有所爱”,如果你想要使用Bootstrap开发自己的项目 ...
- ruby post json
require 'net/http' require 'json' uri = URI('http://localhost/test1.php') req = Net::HTTP::Post.new ...
- module 'pytest' has no attribute 'allure'问题解决
安装allure后执行命令后报错module 'pytest' has no attribute 'allure' C:\Users\Desktop\xin>pytest -s -q --all ...
- python近期遇到的一些面试问题(三)
python近期遇到的一些面试问题(三) 整理一下最近被问到的一些高频率的面试问题.总结一下方便日后复习巩固用,同时希望可以帮助一些朋友们. 前两期点这↓ python近期遇到的一些面试问题(一) p ...
- 2017百度春招<不等式排列>
题目: 度度熊最近对全排列特别感兴趣,对于1到n的一个排列,度度熊发现可以在中间根据大小关系插入合适的大于和小于符号(即 '>' 和 '<' )使其成为一个合法的不等式数列.但是现在度度熊 ...
- git配置用户名跟邮箱
因为我有两个git账号 所以我现在要改变我的默认用户名跟邮件 我就需要去终端设置用户名跟邮箱 具体的命令行就是 设置git的用户名 git config --global user.name &quo ...
- [你必须知道的.NET]第二十四回:认识元数据和IL(上)
发布日期:2009.02.24 作者:Anytao © 2009 Anytao.com ,Anytao原创作品,转贴请注明作者和出处. 说在,开篇之前 很早就有说说Metadata(元数据)和IL(中 ...
- Lab 4 in Tornado
反正也没给CSS,自己改了下样式…… 效果: 题目给的验证信用卡号码规则不太全,万事达的卡第二位必须是1~5,另外其实visa号码也有13位的……要兼容这个的话只要把正则改成'^4([0-9]{12, ...
- hdu5984
听说大佬都是看到1.693147就知道是ln(2)+1我是服气的 不过老老实实推的话就看你大一数分/高数是不是学扎实了 令 把L移到右边并两边求导可得,即 令 代入最开始的公式得到 化简可得,得解 # ...