sgu 169 Numbers
题意:n和n+1同时被数位乘积整除的k位数个数。
假如a是237,b是238。由于个位以前的数一样。那么对于2,如果a%2==0,b%2就!=0,如果a%3==0,b%3就!=0。因此个位以前的数只能是1.再列举个位的情况。
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <cassert>
#define mkp make_pair
using namespace std;
const double EPS=1e-;
const int SZ=,INF=0x7FFFFFFF;
typedef long long lon;
int arr[SZ]; bool chk(const vector<int> &vct,int mod)
{
if(mod==||mod==||mod==)return ;
else if(mod==||mod==)return (vct.size()-)%mod==;
else if(mod==)return (vct.size()-)%==;
else
{
int res=;
for(int i=;i<vct.size();++i)
{
res=res*+vct[i];
res%=mod;
}
return res==;
}
} int main()
{
std::ios::sync_with_stdio();
//freopen("d:\\1.txt","r",stdin);
lon casenum;
//cin>>casenum;
//for(lon time=1;time<=casenum;++time)
{
int n;
cin>>n;
vector<int> vct(n,);
for(int i=;i<;++i)
{
vct[n-]=i;
if(chk(vct,i))arr[i]=;
}
int res=;
for(int i=;i<;++i)
{
if(arr[i]&&arr[i+])++res;
}
cout<<res<<endl;
}
return ;
}
sgu 169 Numbers的更多相关文章
- SGU 169 numbers 数学
169.Numbers Let us call P(n) - the product of all digits of number n (in decimal notation). For exam ...
- SGU 169 Numbers (找规律)
题意:中文题,直接忽略... 析:先说说我的思路,我一看这个题第一感觉就是要找规律,要是挨着算,猴年马月都跑不完,更何况时间限制是0.25s,怎么找规律呢,我算了一下前10位,分别是8,1,1,3,1 ...
- SGU 分类
http://acm.sgu.ru/problemset.php?contest=0&volume=1 101 Domino 欧拉路 102 Coprime 枚举/数学方法 103 Traff ...
- SGU 乱乱开
本解题报告 乱抄,乱写,随性随心,不喜多喷! SGU 142: 思路:一个string的字串不会超过2^20个,我们枚举出来就好了. 我出错点:数组RE #include<stdio.h> ...
- 今日SGU 5.7
SGU 169 题意:求k位数里面有多少个是完美数,完美数的定义就是n是好数,n+1也是好数,那么n就是完美数,好数就是n%p(n)==0&&p(n)!=0,p(n)=a1*...*a ...
- Nearly prime numbers - SGU 113(素数)
题目大意:判断一个数是否是两个素数的乘积,如果是,输出Yes,否则No. 分析:先打表求出来一部分素因子,用素数对素数判定还是比较快的. 代码如下: ========================= ...
- SGU 113.Nearly prime numbers
水一个代码: #include <iostream> using namespace std; int n, a; bool ok; bool prime (int x) { ; i * ...
- SGU 159.Self-Replicating Numbers
时间限制:0.5s 空间限制:6M 题意: 在b(2<b<36)进制中,找到所有长度为n(0<n<2000)的自守数k,满足k^2%b^n=k,字典序输出. ...
- SGU 258 Almost Lucky Numbers 接近幸运数(数位DP)
题意: 定义一个具有2n位的正整数,其前n位之和与后n位之和相等,则为lucky数.给定一个区间,问有多少个正数可以通过修改某一位数从而变成lucky数?注意不能含前导0. 思路: 我的想法是记录那些 ...
随机推荐
- Bootstrap3基础 img-responsive 响应式图片
内容 参数 OS Windows 10 x64 browser Firefox 65.0.2 framework Bootstrap 3.3.7 editor ...
- Python logging 模块学习
logging example Level When it's used Numeric value DEBUG Detailed information, typically of interest ...
- P2234 [HNOI2002]营业额统计(Splay树)题解
思路:Splay数查找前驱后继 代码: #include<iostream> #include<cstdio> #include<cstring> #include ...
- p3302 [SDOI2013]森林(树上主席树+启发式合并)
对着题目yy了一天加上看了一中午题解,终于搞明白了我太弱了 连边就是合并线段树,把小的集合合并到大的上,可以保证规模至少增加一半,复杂度可以是\(O(logn)\) 合并的时候暴力dfs修改倍增数组和 ...
- Katana的WebAPI集成Swagger 解决方案
这位大哥写的博客很清楚了,我就不重复了. http://www.cnblogs.com/caodaiming/p/4156476.html 错误解决 http://blog.csdn.net/gold ...
- 4、iptables扩展匹配及网络防火墙功能
关于centos7 firewalld http://www.ibm.com/developerworks/cn/linux/1507_caojh/index.html 如何保存及重载规则: ...
- Leetcode118_Pascal's Triangle_Easy
Given a non-negative integer numRows, generate the first numRows of Pascal's triangle. In Pascal's t ...
- tkinter 打包成exe可执行文件
1.安装pyinstaller pip install pyinstaller 2.打包 打开cmd,切换到需要打包的文件(demo.py)目录.执行 pyinstaller -F -w demo.p ...
- python+unittet在linux与windows使用的区别
使用python的unittest编写单元测试框架,批量运行测试用例时,如果使用discover时,windows环境下和linux环境下的代码不一样 Windows环境的run.py代码: case ...
- ASP.net 网站开发知识点总结
一.常用技术概括及介绍 1. SQL server:处理数据库的设计 2. asp.net 3. html :前端网页 4. css :网页的布局设计 5. JavaScrip ...