Uva11029-leading and Trailing

Source: Internet
Author: User

Leading and Trailing

Apart from the novice programmers, all others know so you can ' t exactly represent numbers raised
To some high power. For example, the C function pow (125456, 455) can is represented in double data
Type format, but you won ' t get all the digits of the result. However we can get at least some satisfaction
If we could know few of the leading and trailing digits. This is the requirement of this problem.


Input
The first line of input would be an integer T < 1001, where T represents the number of test cases. each
Of the next T lines contains-positive integers, n and K. N would fit in the net bit integer and K would be is less
than 10000001.


Output
For each line of input there would be a line of output. It'll be the of the format LLL ... T T T, where
LLL represents the first three digits of n
K-T T T represents the last three digits of n,k. You areassured that n,k would contain at least 6 digits.


Sample Input
2
123456 1
123456 2


Sample Output
123...456
152...936

Test instructions: to N,k; the first three and the last three digits of the K-side of N

Tip: The last three bits take the remainder 1000, the first three bits such as: X=123456=1.23456*10^5, then log10 (x) =log10 (1.23456) +5; LOG10 (1.23456) =y; 10^y=1.23456

The first three digits are 10^y*100; Note that the last three bits may have a 0 presence in front.

1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cmath>5 #definell Long Long6 7 using namespacestd;8 9 /*ll Power1 (ll A,ll b)Ten { One int ans=a; A for (int i=1;i<b;i++) - ans=ans*a%1000; - return ans%1000; the }*/ -ll Power1 (ll a,ll N)///Two-point POW - { -ll ans=1; +      while(n) -     { +         if(n&1)///for Odd Aans=ans*a% +; ata=a*a% +; -N/=2; -     } -     returnans% +; - } -  in ll Power2 (ll A,ll b) - { to ll P,q,ans; +     Doublef=b*log10 (a); -Q= (LL) F;///Integer Part theP= (LL) (f*10000000)-q*10000000;///*10000000 of small number parts *     Doublex=1.0*p/10000000; $Ans= (LL) (POW (Ten, x) * -);Panax Notoginseng     returnans; - } the  + intMain () A { the ll N,k; +     intT; -Cin>>T; $      while(t--) $     { -Cin>>n>>K; -ll P=power2 (n,k), q=Power1 (n,k); theprintf"%lld...%03lld\n", p,q); -     }Wuyi     return 0; the}

Uva11029-leading and Trailing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.