LeetCode Integer to Roman
摘要:链接: https://oj.leetcode.com/problems/integer-to-roman/题目上已经说最大出现的整型值为3999,这样就很简单了。class Solution{ public: string intToRoman(int num) { string ans;...
阅读全文
Add Two Numbers
摘要:链接:https://oj.leetcode.com/problems/add-two-numbers/链表的大数加法/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode ...
阅读全文
LeetCode Add Binary
摘要:链接: https://oj.leetcode.com/problems/add-binary/大数加法.二进制class Solution{ public: string addBinary(string a,string b) { bool sign=false; string an...
阅读全文
HDU 2104 hide handkerchief
摘要:链接:http://acm.hdu.edu.cn/showproblem.php?pid=2104判断一下n,和m的最大公约数是否为1就可以了#include using namespace std;long long gcd(long long a,long long b){ if(b==0...
阅读全文
NYOJ 912 领帽子
摘要:链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=912全错位排列,按照欧拉给出的递推公式:f(n)=(n-1) {f(n-1)+f(n-2)}#include using namespace std;int main(){ long long ...
阅读全文
HDU 2710 Max Factor
摘要:链接:http://acm.hdu.edu.cn/showproblem.php?pid=2710这道题有点问题,,,是多组数据,要用while(cin),,或者whlie(scanf("")!=EOF)另,要把1当成素数处理.......#include using namespace std;b...
阅读全文
NYOJ 127 星际之门(一)
摘要:链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=127//cayley定理#include using namespace std;int main(){ int x,ans,i,m; scanf("%d",&x); while(x--) { ...
阅读全文
HDU 1395 2^x mod n = 1
摘要:链接:http://acm.hdu.edu.cn/showproblem.php?pid=1395欧拉定理 如果gcd(a,m)==1,a^(euler_phi(n))≡1(mod n)。euler_phi(n)为欧拉函数,其作用是返回与小于n且与n互质的数的个数...令m=euler_phi(n)...
阅读全文
NYOJ 28 大数阶乘
摘要:链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=28大数问题。模拟手工运算,用一个变量储存进位:被乘数逐位乘以乘数。#include #include #include int ans[20000];char tem[5];int t; ...
阅读全文
ZJU 1272 Numerically Speaking
摘要:大数问题......根据先余为低位,后余为高位的基本思想,进行26->10进制的互相转换。注意如果输入为的10进制数为26的整数时,要先减一再求余,最后结果在加a..因为目标进制没有表示0的数Presentation Error 了好几次。。要看到这句话“and the corresponding ...
阅读全文
NYOJ 102 次方求模
摘要:链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=102用二分求幂:注意要用长整形 #include int main(){ long long power(int a,int b,long long c); int n; int a,b,c; ...
阅读全文
ZJU Least Common Multiple
摘要:#include#includeint *data;int main(){ void lcm(int n); int m; int n; int i; scanf("%d",&m); while(m--) { scanf("%d",&n); data=(int *)malloc(sizeo...
阅读全文
HDU 1097 A hard puzzle
摘要:链接:http://acm.hdu.edu.cn/showproblem.php?pid=1097只考虑最后一位即可。 因为(0int main(){ int power(int a,int b); int a,b; int i; int ans; while(scanf("%d%d",&a,&b)...
阅读全文
HDU 2095 find your present (2)
摘要:链接:http://acm.hdu.edu.cn/showproblem.php?pid=2095这道题对内存限制比较大,Memory Limit: 32768/1024 K (Java/Others);根本不可能开大数组来计数。自己做的时候各种超内存。后来看了网上大神的思路:按位异或有这样的性质:...
阅读全文