博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
数学 Codeforces Round #282 (Div. 2) B. Modular Equations
阅读量:6708 次
发布时间:2019-06-25

本文共 1282 字,大约阅读时间需要 4 分钟。

 

题意:a % x == b,求符合条件的x有几个

数学:等式转换为:a == nx + b,那么设k = nx = a - b,易得k的约数(>b)的都符合条件,比如a=25 b=1,那么24,12, 8, 6, 4, 3, 2都可以,所以只要求出k的约数有几个就可以了,a <= b的情况要特判

 

/************************************************
* Author        :Running_Time
* Created Time  :2015-8-19 18:49:21
* File Name     :A.cpp
************************************************/
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <cstdlib>
#include <ctime>
using namespace std;
#define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
typedef long long ll;
const int MAXN = 1e5 + 10;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
int divisor(int n, int b)   {
   int ret = 0;
   for (int i=1; i*i<=n; ++i)    {
       if (n % i == 0) {
           if (i > b)  ret++;
           if (n / i != i && n / i > b)    ret++;
       }
   }
   return ret;
}
int main(void)    {
    //Codeforces Round #282 (Div. 2) B. Modular Equations
   int a, b;   scanf ("%d%d", &a, &b);
   if (a < b)  {
       puts ("0"); return 0;
   }
   if (a == b) {
       puts ("infinity");  return 0;
   }
   int ans = divisor (a - b, b);
   printf ("%d\n", ans);
   return 0;
}

 

转载于:https://www.cnblogs.com/Running-Time/p/4744474.html

你可能感兴趣的文章
开源项目学习方法
查看>>
block的使用
查看>>
使用Toolbar自定义布局的时候左边右边总有一点空间无法使用
查看>>
Photoshop 常用快捷键
查看>>
外观模式
查看>>
Extjs 4 grid修改某一行style
查看>>
background-position设置无效问题解决
查看>>
对称加密算法-DES
查看>>
Android BroadcastReceiver
查看>>
我的友情链接
查看>>
我的友情链接
查看>>
jar包版本冲突问题
查看>>
物联网世界常见传输方式简介(思维导图)
查看>>
KSM导致的警告“ ksmtuned .... read-only system ” 的一些说明
查看>>
Objective C中数组排序的三种方法
查看>>
dedecms验证自定义表单不为空
查看>>
用户测评 | EDAS Serverless 上手体验
查看>>
mysql导出xls的格式
查看>>
开发者招聘节 | 2019阿里巴巴技术面试题分享(陆续放出)
查看>>
Linux 虚拟化实践之KVM
查看>>