F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Miaomiao's Function

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 465    Accepted Submission(s): 217


Problem Description
Firstly , Miaomiao define two functions f(x) , g(x):


(K is the smallest integer which satisfied x + 9 * K > 0)

if e.g. g(178) = 1 - 7 + 8 = 2 , g(1) = 1 , g(1234) = 1 - 2 + 3 - 4 = -2;

For example f(20140810) = f(2 + 0 + 1 + 4 + 0 + 8 + 1 + 0) = f(16) = f(1 + 6) = f(7) = 7

Then , you are given two integers L , R( L <= R) .
Answer is defined as .
Please caculate (Answer Mod f(Answer) + f(Answer)) Mod f(Answer).
Pay attantion ! If f(Answer) = 0 , please output "Error!"
 

Input
There are many test cases. In the first line there is a number T ( T <= 50 ) shows the number of test cases.
For each test cases there are two numbers L ,R ( 0 <= L,R <= 10^100 ).

For your Information , L , R don't have leading zeros.
 

Output
For each opeartion , output the result.
 

Sample Input
2 0 0 0 21
 

Sample Output
Error! 1
 

Hint
The Answer is 0 and 13.
So the result is Error! and 13 Mod (1 + 3) = 1
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-19 11:32:35, Gzip enabled