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

zoj 2681 Pocket Ball

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

zoj 2681 Pocket Ball

#include<cstdio>#include<cstring>#include<iostream>#define SD(x) scanf("%d",&x)#define FOR(i,a,b) for(int i=a;i<=b;i++)#define FF(i,n) for(int i=0;i<n;i++)using namespace std;const int maxn= 100005;char str[maxn];int sb_top;int GCD(int a, int b){ if (a>b) swap(a,b); static int t; for(;t=b;b=a%b, a=t); return a;}int main(){ int nca; SD(nca); while(nca--){ int x, y; SD(y); SD(x); int k= GCD(x, y); y/= k, x/= k; int last= 0; sb_top= 0; FOR(i,1,x){ double tmp= (double)i/x*y; int h= (int)(tmp); FOR(sb, last+1, h){ if (sb%2==1) { str[sb_top++]= 'N'; } else str[sb_top++]= 'S'; } if (i%2==1) str[sb_top++]= 'E'; else str[sb_top++]= 'W'; last= h; } sb_top-= 2; printf("%dn", sb_top); FF(i,sb_top){ printf("%c ", str[i]); } int tmp; if (x%2==1){ if (y%2==1) tmp= 3; else tmp= 2; }else { if (y%2==1) tmp= 4; else tmp= 1; } printf("%d", tmp); puts(""); }}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/375558.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

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

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