摘要: Description The digital root of a positive integer is found by summing the digits of the integer. If the resulting value is a single digit then that d... 阅读全文
posted @ 2015-06-04 17:37 Vmetrio 阅读(212) 评论(0) 推荐(0)
摘要: 下面是 m^n % k 的快速幂: 1 // m^n % k 2 int quickpow(int m,int n,int k) 3 { 4 int b = 1; 5 while (n > 0) 6 { 7 if (n & 1) 8 ... 阅读全文
posted @ 2015-06-04 17:34 Vmetrio 阅读(187) 评论(0) 推荐(0)
摘要: DescriptionGiven a positive integer N, you should output the most right digit of N^N. InputThe input contains several test cases. The first line of th... 阅读全文
posted @ 2015-06-04 17:30 Vmetrio 阅读(173) 评论(0) 推荐(0)
摘要: DescriptionGiven a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the ma... 阅读全文
posted @ 2015-06-04 17:27 Vmetrio 阅读(209) 评论(0) 推荐(0)
摘要: 在网站上一直没有找到有关于快速幂算法的一个详细的描述和解释,这里,我给出快速幂算法的完整解释,用的是C语言,不同语言的读者只好换个位啦,毕竟读C的人较多~所谓的快速幂,实际上是快速幂取模的缩写,简单的说,就是快速的求一个幂式的模(余)。在程序设计过程中,经常要去求一些大数对于某个数的余数,为了得到更... 阅读全文
posted @ 2015-06-04 16:55 Vmetrio 阅读(474) 评论(0) 推荐(0)
摘要: 1 #include 2 using namespace std ; 3 int gcd(int a,int b) 4 { 5 if(a%b!=0) 6 return gcd(b,a%b); 7 else 8 return b ; 9 }10... 阅读全文
posted @ 2015-06-02 21:18 Vmetrio 阅读(289) 评论(0) 推荐(0)
摘要: 1 #include 2 using namespace std; 3 int main() 4 { 5 int N,i=1,A,B,C; 6 cin>>N; 7 while(i>A>>B>>C;10 if(A+B>C&&C+B>A&&C+A>B)11 ... 阅读全文
posted @ 2015-06-02 21:16 Vmetrio 阅读(196) 评论(0) 推荐(0)
摘要: 1 #include 2 using namespace std; 3 int main() 4 { 5 int n ; 6 while(cin>>n) { 7 cout << n*(n+1)/2 << endl << endl ; 8 } 9 ... 阅读全文
posted @ 2015-06-02 21:12 Vmetrio 阅读(135) 评论(0) 推荐(0)
摘要: 1 #include 2 #include 3 #include 4 using namespace std; 5 int main() 6 { 7 int i,n=0,m,a; 8 bool prime; 9 cin>>a;10 for(m=101;m<=2... 阅读全文
posted @ 2015-06-02 21:11 Vmetrio 阅读(161) 评论(0) 推荐(0)
摘要: #includeusing namespace std;int gcd(int a,int b){ if(a%b!=0) return gcd(b,a%b); else return b ;}int main() { int a,b; w... 阅读全文
posted @ 2015-06-02 21:10 Vmetrio 阅读(115) 评论(0) 推荐(0)