lightoj 1078 - Integer Divisibility 暴力数学
来源:互联网 发布:java oa系统源码 编辑:程序博客网 时间:2024/06/05 16:49
给定一个n和x,问最少多少个x组成的数字可以整除n...
直接暴力,依次枚举x的数量...
因为没想到其他做法只能尝试暴力了..没想到过了。
大概是如果有解的话余数最多出现n个...所以n次内必然有解?n*t貌似不超时
#include<bits/stdc++.h>using namespace std;#define ll long long#define ull unsigned long long#define mod 1000007#define inf 0x3f3f3f3f#define N 100100using namespace std;int main(){ int t; scanf("%d",&t); for(int cas=1; cas<=t; cas++) { int n,x; scanf("%d %d",&n,&x); int y=x%n; int ans=1; while(y!=0) { y=y*10+x; ans++; y=y%n; } printf("Case %d: %d\n",cas,ans); } return 0;}
0 0
- lightoj 1078 - Integer Divisibility 暴力数学
- LIGHTOJ-1078 - Integer Divisibility
- LightOJ-1078 Integer Divisibility
- 【简单】LightOJ Integer Divisibility 1078
- lightoj 1078 - Integer Divisibility 【同余】
- LightOJ 1078 - Integer Divisibility (同余定理)
- lightoj 1078 - Integer Divisibility 【同余定理】
- LightOJ 1078 - Integer Divisibility【同余】
- lightoj-1078-Integer Divisibility【大数除法】
- 【 LightOJ 1078 Integer Divisibility + 同余定理 】
- LightOJ 1078 Integer Divisibility (同余定理)
- Light OJ 1078:Integer Divisibility【数学】
- Light OJ 1078:Integer Divisibility【数学】
- LightOJ 1078 - Integer Divisibility(取模运算)
- LightOJ 1078 Integer Divisibility (同余定理)
- LightOJ 1078 Integer Divisibility (同余定理 )
- 【Light】[1078]Integer Divisibility
- 1078 - Integer Divisibility
- 使用JMX监控Tomcat
- HBase简介
- TS流详细解析
- Struts2 获取 Session对象
- centos7使用devstack安装openstack mitaka
- lightoj 1078 - Integer Divisibility 暴力数学
- 【学习清单】我的Android学习清单
- VS2013打包程序 详细步骤
- mac下配置svn
- 始
- 剑指offer-面试题42:翻转单词顺序VS左旋转字符串
- 求最大公约数与最小公倍数
- LeetCode - Best Time to Buy and Sell Stock
- zzuli 1728: 社交网络(求期望值)