# 51nod1185 (wythoff+ high precision)

Source: Internet
Author: User

Test instructions: Chinese question eh ~

Idea: Wythoff template problem, and 51nod1072 basically the same (http://www.cnblogs.com/geloutingyu/p/6198094.html), but the data is relatively large (1e18), there will be precision problems;

We can:

Order: Cnt=abs (x-y);

Geloutingyu=1e9;

a[3]={618033988, 749894848, 204586834} ((sqrt (5) +1)/2=1.618033988749894848204586834, we can first not calculate 1, and finally add a CNT on the good);

Pre=cnt/geloutingyu------1;

Las=cnt%geloutingyu-----2;

Gg=cnt+cnt*a[0]/geloutingyu+cnt*a[1]/mod/mod+cnt*a[2]/mod/mod/mod-----3;

United 1, 2 is cnt=pre*geloutingyu+las------4;

The 4 is then brought into the 3, with:

Gg=cnt+pre*a[0]+las*a[0]/mod+pre*a[1]/mod+las*a[1]/mod/mod+pre*a[2]/mod/mod+las*a[2]/mod/mod/mod----5;

We re-order: ans1=las*a[2], then there are:

Gg=cnt+pre*a[0]+las*a[0]/mod+pre*a[1]/mod+las*a[1]/mod/mod+pre*a[2]/mod/mod+ (ans1)/mod/mod/mod;

We re-order: Ans2=las*a[1]+pre*a[2]+ans1/mod, there are:

Gg=cnt+pre*a[0]+las*a[0]/mod+pre*a[1]/mod+ (ANS2)/mod/mod;

We re-order: Ans3=las*a[0]+pre*a[1]+ans2/mod, there are:

gg=cnt+pre*a[0]+ (ANS3)/mod;

So we just have to find out ans1, ANS2, ANS3 can solve the GG ...

Code:

`1#include <bits/stdc++.h>2 #definell Long Long3 #defineGeloutingyu 10000000004 using namespacestd;5 6ll a[3]={618033988,749894848,204586834};7 8 intMainvoid){9     intT;Ten ll x, y; Onescanf"%d", &t); A      while(t--){ -scanf"%lld%lld", &x, &y); -         if(x>y) { the swap (x, y); -             } -ll cnt=y-x; -ll Pre=cnt/geloutingyu, las=cnt%Geloutingyu; +ll ans1=las*a[2]; -ll ans2=pre*a[2]+las*a[1]+ans1/Geloutingyu; +ll ans3=pre*a[1]+las*a[0]+ans2/Geloutingyu; All gg=cnt+pre*a[0]+ans3/Geloutingyu; at         if(gg==x) { -printf"b\n"); -}Else{ -printf"a\n"); -         } -     } in     return 0; -}`

51nod1185 (wythoff+ high precision)

Related Keywords:

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.