UVA 10127- Ones 数学】的更多相关文章

题目链接:uva 10127 - Ones 题目大意:给出n,问说者少要多少为1才干够整除n. 解题思路:等于是高精度取模,直到余数为0为止. #include <cstdio> #include <cstring> int main () { int n; while (scanf("%d", &n) == 1) { int ans = 1, c = 1; while (c) { c = (c * 10 + 1) % n; ans++; } print…
大致题意:给出几个包裹,每个包裹都包装好了3种大小的杯子.现在要重新包装,使向量 a[1]*(s[1][1],s[1][2],s[1][3])+a[2]*(s[2][1],s[2][2],s[2][3])+.....+a[n]*(s[n][1],s[n][2],s[n][3])=(k,k,k). 就这样转化成了向量问题其中a[i]为非负整数,k为正整数. 虽然转化成了向量问题,但是三维向量和这么多变量有点棘手,所以我们可以先降维,将原等式变化成: a[1]*(s[1][2]-s[1][1],s[…
感觉数学期望的和化学里面求元素的相对原子质量的算法是一样的 就是同位素的含量乘上质量然后求和得出 这道题因为等待时机是0到2*l/v均匀分配的,所以平均时间就是l/v 再加上过河的l/v, 最后加上步行的时间就ok了 #include<cstdio> #define REP(i, a, b) for(int i = (a); i < (b); i++) using namespace std; int main() { int n, D, kase = 0; while(~scanf(&…
UVa 10323 题目:计算阶乘在10000~6227020800之间的值,不在范围对应输出Under或者Over. 分析:简单题.数论.因为13!=6227020800,7!<10000<8!所以计算很简单. 注意:负数情况,奇数输出Overflow,偶数输出Underflow. 其实我不明白为什么小于零时要分奇偶!而且阶乘会小于零么? #include<iostream> using namespace std; int main() { int n; while(cin&g…
题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=83008#problem/E Description HINT 题意: 给你一个水池,水池中放一个东西,上面一双眼睛,问眼睛能看到东西时,水面的最小高度 题解: 列列方程就是了 #include <cstdio> #include <cmath> #include <cstring> #include <ctime> #include &l…
#include <iostream>#include <cstdio>#include <cmath> int main(){ int num; while (scanf_s("%d",&num) != EOF) { int cnt = 2; long long testNum = 11; while (true) { if (testNum%num == 0) { break; } testNum = testNum * 10 + 1;…
Given any integer 0 ≤ n ≤ 10000 not divisibleby 2 or 5, some multiple of n is a number whichin decimal notation is a sequence of 1’s. Howmany digits are in the smallest such a multipleof n?InputA file of integers at one integer per line.OutputEach out…
题目链接 题意:给你一个数n,问最少有多少个1构成的“1”串(1,11,...)能整除n; 比如:111能被3整除: 111111能被7整除:... 作为水货觉得只要自己能1A的都是水题=. = #include<iostream> #include<cstdio> #include<cstdlib> #include<cmath> using namespace std; ; int main() { int n, p[maxn]; while(~scan…
Bryce1010模板 10.1数论初步 1.欧几里得算法和唯一分解定理 2.Eratosthenes筛法 补充素数筛选 const int MAXN=1e6+10; ll prime[MAXN]; void getPrime(int maxn) { memset(prime,0,sizeof(prime)); for(int i=2;i<=maxn;i++) { if(!prime[i])prime[++prime[0]]=i; for(int j=i;j<=prime[0]&&am…
 The ? 1 ? 2 ? ... ? n = k problem  The problem Given the following formula, one can set operators '+' or '-' instead of each '?', in order to obtain a given k ? 1 ? 2 ? ... ? n = k For example: to obtain k = 12 , the expression to be used will be: -…