題意:輸出一串數位中間數。題解:#include <iostream>using namespace std;void quiksort ( int * array, int left, int right ){if ( left < right ){int s = array [( left + right ) / 2]; int l = left - 1, r = right + 1; while ( 1 ){while ( array[++l]
題意: Given an integer N(1 < N < 2^31),you are to calculate ∑gcd(i, N) 1<=i <=N.題解:公式:f(N)=∑x*φ(N/x),x | N (x是N的約數)因為在1···N中,gcd(i,N) = x, 的個數的等於φ(N / x)另外還可以利用函數的積性:對於正整數n的一個函數 f(n),當中f(1)=1且當a,b互質,f(ab)=f(a)f(b),在數論上就稱它為積性函數。若某函數f(n)符合f(1
E. Zero-Onetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle Petya very much likes playing with little Masha. Recently he has received a game called "Zero-One" as a gift from his mother.
小M的迴文串Description小M喜歡迴文串,迴文串就是從左往右和從右往左讀都一樣的字串。現在小X找到小M給了他一個字串S,希望小M將它變成迴文串。小M可以進行如下三類操作:add 在字串的任意位置添加一個字元erase 刪除一個字元change one letter to another 將某個字元變成另一個然而,每種操作只能對規定的字元有效。如,小M只能允許erase 'a', add 'b', change 'c' to 'd',且沒有其他動作可以使用。
【問題描述】Consider an arbitrary sequence ofintegers. One can place + or - operators between integers in the sequence, thusderiving different arithmetical expressions that evaluate to different values.Let us, for example, take the sequence: 17, 5, -21, 15
D. Rectangle and Squaretime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle Petya very much likes rectangles and especially squares. Recently he has received 8 points on the plane as a gift