题意: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的更多相关文章

  1. SGU 169 numbers 数学

    169.Numbers Let us call P(n) - the product of all digits of number n (in decimal notation). For exam ...

  2. SGU 169 Numbers (找规律)

    题意:中文题,直接忽略... 析:先说说我的思路,我一看这个题第一感觉就是要找规律,要是挨着算,猴年马月都跑不完,更何况时间限制是0.25s,怎么找规律呢,我算了一下前10位,分别是8,1,1,3,1 ...

  3. SGU 分类

    http://acm.sgu.ru/problemset.php?contest=0&volume=1 101 Domino 欧拉路 102 Coprime 枚举/数学方法 103 Traff ...

  4. SGU 乱乱开

    本解题报告 乱抄,乱写,随性随心,不喜多喷! SGU 142: 思路:一个string的字串不会超过2^20个,我们枚举出来就好了. 我出错点:数组RE #include<stdio.h> ...

  5. 今日SGU 5.7

    SGU 169 题意:求k位数里面有多少个是完美数,完美数的定义就是n是好数,n+1也是好数,那么n就是完美数,好数就是n%p(n)==0&&p(n)!=0,p(n)=a1*...*a ...

  6. Nearly prime numbers - SGU 113(素数)

    题目大意:判断一个数是否是两个素数的乘积,如果是,输出Yes,否则No. 分析:先打表求出来一部分素因子,用素数对素数判定还是比较快的. 代码如下: ========================= ...

  7. SGU 113.Nearly prime numbers

    水一个代码: #include <iostream> using namespace std; int n, a; bool ok; bool prime (int x) { ; i * ...

  8. SGU 159.Self-Replicating Numbers

    时间限制:0.5s 空间限制:6M 题意:         在b(2<b<36)进制中,找到所有长度为n(0<n<2000)的自守数k,满足k^2%b^n=k,字典序输出.   ...

  9. SGU 258 Almost Lucky Numbers 接近幸运数(数位DP)

    题意: 定义一个具有2n位的正整数,其前n位之和与后n位之和相等,则为lucky数.给定一个区间,问有多少个正数可以通过修改某一位数从而变成lucky数?注意不能含前导0. 思路: 我的想法是记录那些 ...

随机推荐

  1. SpringBoot 使用Hikaricp连接池

    1.添加pom.xml依赖 如果是SpringBoot2.0,那么默认的连接池就是Hikaricp,不需要配置 其他的,如果继承 <parent> <groupId>org.s ...

  2. 【控制分片分配】控制Elasticsearch分片和副本的分配

    ES集群中索引可能由多个分片构成,并且每个分片可以拥有多个副本.通过将一个单独的索引分为多个分片,我们可以处理不能在一个单一的服务器上面运行的大型索引,简单的说就是索引的大小过大,导致效率问题.不能运 ...

  3. awk - group adjacent rows by identical columns

    Liang always brings me interesting quiz questions. Here is one: If i have a table like below: chr1 1 ...

  4. R语言之正则表达式

    常见与正则表达式相关的函数: grep(pattern, x, ignore.case = FALSE, perl = FALSE, value = FALSE, fixed = FALSE, use ...

  5. 分布式强化学习基础概念(Distributional RL )

    分布式强化学习基础概念(Distributional RL) from: https://mtomassoli.github.io/2017/12/08/distributional_rl/ 1. Q ...

  6. 用yarn代替cnpm,cnpm漏包有点严重

    npm 的方式  npm  install  -g  yarn   安装完成后,你可以测试下自己的版本 yarn --version 开始使用 单独安装包的方式add 不是install,后面不用加 ...

  7. .net 打包下载

      ZipArchive 打包下载 private IActionResult DownloadZipFromUrl(string[] guids,string zipFullName) { usin ...

  8. 分布式爬虫scrapy-redis中settings.py中的配置信息

    SCHEDULER = "scrapy_redis.scheduler.Scheduler" # 使用scrapy-redis的调度器 ITEM_PIPELINES = { 'sc ...

  9. jquery.validate使用详解

    一.简单应用实例: 1.用class样式进行验证,用法简单,但不能自定义错误信息,只能修改jquery-1.4.1.min.js中的内置消息,也不支持高级验证规则. <script type=& ...

  10. MVC ---- 去掉HTML过滤

    在方法头上添加特效  [ValidateInput(false)]  富文本框提交的内容就可以顺利提交到后台了.