美团codeM预赛B 模
来源:互联网 发布:adobeillustrator mac 编辑:程序博客网 时间:2024/05/27 00:41
模
时间限制:1秒
空间限制:32768K
给定四个正整数a,b,c,k,回答是否存在一个正整数n,使得a*n在k进制表示下的各位的数值之和模b为c。
输入描述:
第一行一个整数T(T <= 5,000)。 接下来T行,每行四个正整数a,b,c,k(1 ≤ a ≤ 10^18; 2 ≤ k ≤ 10^18; 0 ≤ c < b ≤ 10^18)表示一个询问,所有输入都是十进制的。
输出描述:
对于每组数据输出一行,Yes表示存在,No表示不存在。
输入例子1:
23 9 5 107 3 1 10
输出例子1:
NoYes
#include <iostream> #include <cstdio> #include <cstring> #include <string> #include <algorithm> #include <queue> #include <stack> #include <cmath> #include <map> #include <bitset> #include <set> #include <vector> #include <functional> using namespace std; #define LL long long const int INF = 0x3f3f3f3f; LL gcd(LL a,LL b){ return b?gcd(b,a%b):a;}int main(){ int t; LL a,b,c,k; scanf("%d",&t); while(t--) { scanf("%lld%lld%lld%lld",&a,&b,&c,&k); LL sum=0; while(a) {sum+=a%k;a/=k;} if(c%gcd(b,gcd(sum,k-1))==0) printf("Yes\n"); else printf("No\n"); } return 0;}
阅读全文
0 0
- 美团codeM预赛B 模
- 美团codeM预赛B 子串
- 美团codeM预赛B 黑白树
- 美团codeM预赛B 景区路线规划
- 美团codeM预赛B 送外卖2
- 美团codeM预赛A 倒水
- 美团codeM预赛A轮 倒水
- 美团codeM预赛A 身体训练
- 美团codeM预赛A 合并回文子串
- CodeM美团点评编程大赛资格赛B题
- CodeM美团B轮A题 黑白树 【贪心】
- CodeM美团点评编程大赛初赛B轮
- CodeM美团点评编程大赛初赛B轮题解
- codeM 美团 b轮 A题 黑白树
- codeM 美团b轮 E 子串
- 「美团 CodeM 初赛 Round B」子串
- 美团CODEM 初赛B 景区路线规划 概率DP
- 美团codeM比赛
- 程序员必读书单 1.0
- 初识MyBatis--1
- tf随笔-6
- Deep Learning(深度学习)学习笔记整理系列之(二)
- 旗子翻转
- 美团codeM预赛B 模
- Android布局优化
- C语言大型项目中那些结构体是如何定下来,操作系统里有些结构体特别复杂,好多指针指向链表,他们如何设计?
- goland IDE golang debug的关键
- 对Akka Future的理解(二)
- adb通过wifi连接android设备(魅族note3)
- 菜鸟请教简单c++舞步学院带你解答
- NAT模式与桥接(bridge)模式
- I/O多路复用select服务器