设为首页 加入收藏

TOP

HDOJ 4915 Multiplication table
2015-07-20 17:43:13 来源: 作者: 【 】 浏览:1
Tags:HDOJ 4915 Multiplication table


可以特判出0和1,再统计每行出现了多少种十位上的数就可以了....

没有考虑2的情况似乎也过了......


Multiplication table

Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 800 Accepted Submission(s): 360


Problem Description Teacher Mai has a multiplication table in base p.

For example, the following is a multiplication table in base 4:

* 0 1 2 3
0 00 00 00 00
1 00 01 02 03
2 00 02 10 12
3 00 03 12 21


But a naughty kid maps numbers 0..p-1 into another permutation and shuffle the multiplication table.

For example Teacher Mai only can see:

1*1=11 1*3=11 1*2=11 1*0=11
3*1=11 3*3=13 3*2=12 3*0=10
2*1=11 2*3=12 2*2=31 2*0=32
0*1=11 0*3=10 0*2=32 0*0=23


Teacher Mai wants you to recover the multiplication table. Output the permutation number 0..p-1 mapped into.

It's guaranteed the solution is unique.
Input There are multiple test cases, terminated by a line "0".

For each test case, the first line contains one integer p(2<=p<=500).

In following p lines, each line contains 2*p integers. The (2*j+1)-th number x and (2*j+2)-th number y in the i-th line indicates equation i*j=xy in the shuffled multiplication table.

Warning: Large IO!

Output For each case, output one line.

First output "Case #k:", where k is the case number counting from 1. The following are p integers, indicating the permutation number 0..p-1 mapped into.
Sample Input
4
2 3 1 1 3 2 1 0
1 1 1 1 1 1 1 1
3 2 1 1 3 1 1 2
1 0 1 1 1 2 1 3
0

Sample Output
Case #1: 1 3 2 0

Author xudyh
Source 2014 Multi-University Training Contest 8

#include 
  
   
#include 
   
     #include 
    
      #include 
     
       #include 
      
        using namespace std; int nextInt() { char ch; int ret=0; while(ch=getchar()) { if(ch>='0'&&ch<='9') { ret=ret*10+ch-'0'; } else break; } return ret; } int n,f[510][1010],ans[550],cas=1; bool v1[510],v2[510]; int s1,s2; int main() { while(scanf("%d",&n)!=EOF&&n) { getchar(); for(int i=0;i
       
        



】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇ZOJ 3812 We Need Medicine 01背.. 下一篇hdu1530 Maximum Clique,最大团 ..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·C++中智能指针的性能 (2025-12-25 03:49:29)
·如何用智能指针实现c (2025-12-25 03:49:27)
·如何在 C 语言中管理 (2025-12-25 03:20:14)
·C语言和内存管理有什 (2025-12-25 03:20:11)
·为什么C语言从不被淘 (2025-12-25 03:20:08)