$1\leq C\leq9, 1 \leq S \leq 10, X \geq 2, 1 \leq k \leq 100, 0 \leq Y_i \leq X$

 #include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <iostream>
#include <assert.h>
#define pi acos(-1.)
using namespace std;
typedef long long ll;
const int int_inf = 0x3f3f3f3f;
const ll ll_inf = 0x3f3f3f3f3f3f3f3f;
) - );
;
const double double_inf = 1e30;
typedef unsigned long long ul;
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define mp make_pair
#define st first
#define nd second
#define keyn (root->ch[1]->ch[0])
#define lson (u << 1)
#define rson (u << 1 | 1)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define type(x) __typeof(x.begin())
#define foreach(i, j) for(type(j)i = j.begin(); i != j.end(); i++)
#define FOR(i, s, t) for(int i = (s); i <= (t); i++)
#define ROF(i, t, s) for(int i = (t); i >= (s); i--)
#define dbg(x) cout << x << endl
#define dbg2(x, y) cout << x << " " << y << endl
#define clr(x, i) memset(x, (i), sizeof(x))
#define maximize(x, y) x = max((x), (y))
#define minimize(x, y) x = min((x), (y))
#define low_bit(x) ((x) & (-x))

int x;
scanf("%d", &x);
return x;
}

scanf("%s", s);
return strlen(s);
}

class cmpt{
public:
bool operator () (const int &x, const int &y) const{
return x > y;
}
};

int Rand(int x, int o){
//if o set, return [1, x], else return [0, x - 1]
;
int tem = (int)((double)rand() / RAND_MAX * x) % x;
: tem;
}

void data_gen(){
srand(time());
freopen("in.txt", "w", stdout);
;
printf("%d\n", times);
while(times--){
, ), a = Rand(, ), c = Rand(, );
), d = Rand(r, );
, ), n = Rand(m, );
printf("%d %d %d %d %d %d %d\n", n, m, a, b, c, d, r);
}
}

struct cmpx{
bool operator () (int x, int y) { return x > y; }
};
;
, , , };
, , -, };
//-------------------------------------------------------------------------
int C, S;
ll mt[][];
ll X[], k[];
ll ans[];
ll buf[];
ll w[], _w[];
ll M;
];
pair<pll, ];
const int lim = 1e5;

void egcd(ll a, ll b, ll &d, ll &x, ll &y){
if(!b){
d = a, x = , y = ;
return;
}
egcd(b, a % b, d, x, y);
ll x1 = x, y1 = y;
x = y1, y = x1 - a / b * y1;
}

void dfs(int pos){
){
ll tem = ;
FOR(i, , C) tem += buf[i] * w[i] % M * _w[i] % M, tem %= M;
if(!tem) tem = M;
FOR(i, , S - ) ans[i + S] = tem + M * i;
sort(ans, ans +  * S);
return;
}
FOR(i, , k[pos]){
buf[pos] = mt[pos][i];
dfs( + pos);
}
}

bool cmp(pair<pll, int> x, pair<pll, int> y){
return x.st.st * y.st.nd < x.st.nd * y.st.st;
}

void enu_solve(){
FOR(i, , C) _buf[i] = mp(mp(k[i], X[i]), i);
sort(_buf + , _buf + C + );
FOR(i, , C) id[i] = _buf[i].nd;
;
;
while(cnt < S){
;
FOR(i, , C){
int j = id[i];
int tem = bg % X[j];
int sz = k[j];
;
FOR(u, , sz) ; break; }
; break; }
}
if(ok1) ans[cnt++] = bg;
bg++;
}
}

void crt_solve(){
M = ;
FOR(i, , C) M *= X[i];
FOR(i, , C) w[i] = M / X[i] % M;
FOR(i, , C){
ll d, x, y;
egcd(w[i], X[i], d, x, y);
_w[i] = (x % X[i] + X[i]) % X[i];
}
clr(ans, ll_inf);
dfs();
}

void solve(){
ll num = ;
;
FOR(i, , C){
num *= k[i];
if(num > lim){
ok = ;
break;
}
}
if(ok) crt_solve();
else enu_solve();
}

//-------------------------------------------------------------------------
int main(){
//data_gen(); return 0;
//C(); return 0;
debug = ;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
if(debug) freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
while(~scanf("%d%d", &C, &S) && C){
FOR(i, , C){
FOR(j, , k[i]) mt[i][j] = readint();
}
solve();
FOR(i, , S - ) printf("%lld\n", ans[i]);
printf("\n");
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
;
}

code：

## Uva 11754 Code Feat的更多相关文章

1. UVA 11754 - Code Feat(数论)

UVA 11754 - Code Feat 题目链接 题意:给定一个c个x, y1,y2,y3..yk形式,前s小的答案满足s % x在集合y1, y2, y3 ... yk中 思路:LRJ大白例题, ...

2. UVA 11754 Code Feat （枚举，中国剩余定理）

转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud C Code Feat   The government hackers at C ...

3. UVA 11754 Code Feat 中国剩余定理+暴力

lrj白书例题,真好 #include <stdio.h> #include <iostream> #include <vector> #include <m ...

4. UVa 11754 (中国剩余定理 枚举) Code Feat

如果直接枚举的话,枚举量为k1 * k2 *...* kc 根据枚举量的不同,有两种解法. 枚举量不是太大的话,比如不超过1e4,可以枚举每个集合中的余数Yi,然后用中国剩余定理求解.解的个数不够S个 ...

5. UVA 11754 (暴力+中国剩余定理)

题目链接: http://www.bnuoj.com/v3/problem_show.php?pid=20172 题目大意:有C个模方程,每个方程可能有k余数,求最小的S个解. 解题思路: 看见模方程 ...

6. [kuangbin带你飞]专题十四 数论基础

ID Origin Title   111 / 423 Problem A LightOJ 1370 Bi-shoe and Phi-shoe   21 / 74 Problem B ...

7. UVa 740 - Baudot Data Communication Code

称号:目前编码,他们shift键被按下,并提出,对应的两个编码,其中,2相应的编码shift操作. 给你适当的编码值.寻求相应的字符串. 分析:模拟.字符串. 简单题,标记shift的升降分类处理就可 ...

8. Uva 12436 Rip Van Winkle&amp;#39;s Code

Rip Van Winkle was fed up with everything except programming. One day he found a problem whichrequir ...

9. UVa 1593 (水题 STL) Alignment of Code

话说STL的I/O流用的还真不多,就着这道题熟练一下. 用了两个新函数: cout << std::setw(width[j]);    这个是设置输出宽度的,但是默认是在右侧补充空格 所 ...

## 随机推荐

1. 17.如何修改SESSION的生存时间。

方法1:将php.ini中的session.gc_maxlifetime设置为9999重启apache 方法2:$savePath = "./session_save_dir/"; ... 2. Keras学习～第一个例子～跑MNIST import numpy as npimport gzip import struct import keras as ks import logging from keras.layers impo ... 3. Oracle Database 11g For Windows7 旗舰版的安装 系统环境:win7 32位系统 安装步骤: 1,Oracle(甲骨文)官网下载适合自己的数据库安装包,下载地址http://www.oracle.com/technetwork/cn/indexes/ ... 4. java实现单链表反转 一.简介 经查阅,主要有两种方法实现链表反转,递归反转法和遍历反转法: 递归: 在反转当前结点之前先反转其后边的结点,即.从尾结点开始逆向反转各个节点的指针域指向: 遍历:从前往后反转各个结点的指针域 ... 5. 21. Clone Graph Clone Graph Clone an undirected graph. Each node in the graph contains a label and a list of its nei ... 6. 在Egret实现二维码长按识别 Egret中二维码图片,是在canvas上,无法在微信上长按扫描识别. 由于微信长按识别二维码是截屏扫描原理,所以只要长按当前屏幕任意一张图片,都能够识别当前屏幕上的二维码. 这里把二维码放在ex ... 7. Adobe Illustrator里使用fontawesome矢量图标 简单教程:1.安装FontAwesome.otf字体2.打开http://fontawesome.io/cheatsheet/3.选中图标图片,ctrl+c4.粘贴到AI中5.选中粘贴的内容,修改字 ... 8. footable动态载入数据 footable_redraw事件$('#scan').on('click',function(){ var html = '<tr><td>mayidudu</td& ...

9. Android UI 之 Tab类型界面总结

Android 程序中实现Tab类型界面很常见,本人在做项目的时候也经常用到,所以想在这里总结一下,实现tab类型界面的几种方式,供大家参考.如有不对之处,欢迎大家指正! 一.TabActivity ...

10. IE升级代码时邮件内容

TypeErrorUnable to set property 'value' of undefined or null reference. 但是可以进入添加页面,填完信息后,submit后跳转至 ...