栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

poj 1640 Poly

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

poj 1640 Poly

#include<iostream>#include<sstream>#include<string>#include<cstdio>#include<cstring>#include<vector>#include<queue>#include<map>#include<set>#include<algorithm>using namespace std;#define pb push_back#define all(c) c.begin(), c.end()// 13C#define DBG 1#define sz(c) ((int)(c).size())#define    forl(i, a, b) for(int i = (a); i <  (b); ++i)#define   forle(i, a, b) for(int i = (a); i <= (b); ++i)#define    forg(i, a, b) for(int i = (a); i >  (b); --i)#define   forge(i, a, b) for(int i = (a); i >= (b); --i)#define   forlc(i, a, b) for(int i##_b = (b), i = (a); i <  i##_b; ++i)#define  forlec(i, a, b) for(int i##_b = (b), i = (a); i <= i##_b; ++i)#define   forgc(i, a, b) for(int i##_b = (b), i = (a); i >  i##_b; --i)#define  forgec(i, a, b) for(int i##_b = (b), i = (a); i >= i##_b; --i)#define  forall(i, v   )  forl(i, 0, sz(v))#define forallc(i, v   ) forlc(i, 0, sz(v))#define  forlla(i, v   ) forge(i, sz(v)-1, 0)#define   forls(i, n, a, b) for(int i = a; i != b; i = n[i])#define rep(n)  for(int    repp = 0; repp <    (n); ++repp)#define repc(n) for(int repp_b = (n), repp = 0; repp < repp_b; ++repp)#define rst(a, v) memset(a, v, sizeof a)#define cpy(a, b) memcpy(a, b, sizeof a)#define rstn(a, v, n) memset(a, v, (n)*sizeof((a)[0]))#define cpyn(a, b, n) memcpy(a, b, (n)*sizeof((a)[0]))#define ast(b) if(DBG && !(b)) { printf("%d!!|n", __LINE__); while(1) getchar(); }#define dout DBG && cout << __LINE__ << ">>| "#define pr(x) #x"=" << (x) << " | "#define mk(x) DBG && cout << __LINE__ << "**| "#x << endl#define pra(arr, a, b) if(DBG) {     dout<<#arr"[] | ";     forlec(i, a, b) cout<<"["<<i<<"]="<<arr[i]<<" |"<<((i-(a)+1)%13?" ":"n");     if(((b)-(a)+1)%13) puts("");   }#define rd(type, x) type x; cin >> xinline int     rdi() { int d; scanf("%d", &d); return d; }inline char    rdc() { scanf(" "); return getchar(); }inline string  rds() { rd(string, s); return s; }inline double rddb() { double d; scanf("%lf", &d); return d; }template<class T> inline bool updateMin(T& a, T b) { return a>b? a=b, true: false; }template<class T> inline bool updateMax(T& a, T b) { return a<b? a=b, true: false; }const int N = 64;int n, s, p[N], a[N], b[N], c[N];int nxt_poly(int i) { return a[i] += b[i] += c[i]; }void init_poly(int i) { for(a[i] = b[i] = 1, c[i] = p[i]-2; a[i]<s; nxt_poly(i)) {} }void print_5polypoly() {  static int cas;  if(++cas > 1) puts("");  for(int polys = 0; polys < 5; ) {    int mn = *min_element(a, a+n);    if(count(a, a+n, mn) > 1) {      printf("%d", mn), ++polys;      bool first = true;      forl(i, 0, n)        if(a[i] == mn)          printf("%c%d", first?':':' ', p[i]), first = false;      puts("");    }    forl(i, 0, n) if(a[i] == mn) nxt_poly(i);  }}int main() {  while(scanf("%d", &n)==1 && n) {    forl(i, 0, n) scanf("%d", p+i);    scanf("%d", &s);    forl(i, 0, n) init_poly(i);    print_5polypoly();  }  return 0;}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/379664.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号