ayit第十五周訓練題題i題

2021-10-06 15:36:01 字數 1327 閱讀 3133

you are given two integers:nandk, your task is to find the most significant three digits, and least significant three digits ofnk.

input

input starts with an integert (≤ 1000), denoting the number of test cases.

each case starts with a line containing two integers:n (2 ≤ n < 231)andk (1 ≤ k ≤ 107).

output

for each case, print the case number and the three leading digits (most significant) and three trailing digits (least significant). you can assume that the input is given such thatnkcontains at least six digits.

sample input

5123456 1

123456 2

2 31

2 32

29 8751919

sample output

case 1: 123 456

case 2: 152 936

case 3: 214 648

case 4: 429 296

case 5: 665 669

#include#include#include//#include//using namespace std;

int n,k;

int e(int n,int k)

b1=(b1*b1)%1000;

k/=2;

}return a1;

}int main()

return 0;

}

題意   求乙個數n的k次方後的前三位與後三位。並且後三位要求控制格式

思路   後三位可以用快速冪求出來,前三位要用到log了

double p=k*log10(n);

p=p-(int)p;

int ans=(int)(pow(10,p)*100);

前三位求法。

ayit 第十五周訓練f題

give a number n,find the minimum x x 0 that satisfies 2 x mod n 1.input one positive integer on each line,the value of n.output if the minimum x exist...

ayit第十三周訓練d題

某省自從實行了很多年的暢通工程計畫後,終於修建了很多路。不過路多了也不好,每次要從乙個城鎮到另乙個城鎮時,都有許多種道路方案可以選擇,而某些方案要比另一些方案行走的距離要短很多。這讓行人很困擾。現在,已知起點和終點,請你計算出要從起點到終點,最短需要行走多少距離。input 本題目包含多組資料,請處...

ayit五一訓練 b題

在紡織cad系統開發過程中,經常會遇到紗線排列的問題。該問題的描述是這樣的 常用紗線的品種一般不會超過25種,所以分別可以用小寫字母表示不同的紗線,例如 abc表示三根紗線的排列 重複可以用數字和括號表示,例如 2 abc 表示abcabc 1 a 1a表示a 2ab表示aab 如果括號前面沒有表示...