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

Great Sequence

Time Limit: 10000/10000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 314    Accepted Submission(s): 51


Problem Description
A great sequence S is a sequence contains N decimal integers, i.e. S = (x[1], x[2], ..., x[N]). S should also satisfy following rules:
a[i] ¡Ü x[i] ¡Ü b[i]
ds[i] c[i] ds[i+1], where ds[i] is the digit sum of x[i] and c[i] is one of the following relational operators: "=", "<", "<=", ">", ">=" and "!=".
Obviously, there are a lot of great sequences. You are asked to find the K-th least great sequence in lexicographic order.
 

Input
There are multiple test cases. Process to the End of File.
The first line of each test case contains two integers 1 ¡Ü N ¡Ü 100, 1 ¡Ü K ¡Ü 1016, as described above.
In the next N-1 lines, each line contains three elements, a[i], b[i] and c[i], where a[i] and b[i] are integers (1 ¡Ü a[i] ¡Ü b[i] ¡Ü 1018) while c[i] is one of the following strings: "=", "<", "<=", ">", ">=" and "!=".
The last line of each test cases contains only two integers, a[N] and b[N] (1 ¡Ü a[N] ¡Ü b[N] ¡Ü 1018).
 

Output
For each test case, if the total number of great sequences is less than K, output "OUT OF RANGE" (without quotes); otherwise, output the K-th least great sequence in one line. Numbers in the sequence are separated by a single space.
 

Sample Input
3 15 9 10 <= 99 100 = 1 300 3 20 9 10 <= 99 100 = 1 300
 

Sample Output
10 100 100 OUT OF RANGE
 

Author
Zejun Wu (watashi)
 

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-11-22 16:40:22, Gzip enabled