HDU 4952 Number Transformation (query rule)

Source: Internet
Author: User

HDU 4952 Number Transformation (query rule)

 

Perform K operations. The I operation converts X to the maximum integer not less than X, and X is a multiple of I. The value of X after K operations.

The violence of the red fruit will time out. The brute-force table shows a pattern after 12000. The difference between the following two is constant.

 

 

 

AC code:

 

 

# Include

 
  
# Define ll _ int64const ll maxn = 120000; int main () {ll I; ll x, k; int cas = 1; while (scanf (% I64d % I64d, & x, & k )! = EOF) {if (x = 0 & k = 0) break; printf (Case # % d:, cas ++); if (k <= maxn) {for (I = 1; I <= k; I ++) if (x % I! = 0) x = I * (x/I + 1); printf (% I64d, x);} else {ll y; for (I = 1; I <= maxn; I ++) if (x % I! = 0) x = I * (x/I + 1); y = I * (x/I + 1); printf (% I64d, x + (k-maxn) * (y-x) ;}} return 0 ;}

 


 

 

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.