转自http://acm.cist.bnu.edu.cn
1、判题系统使用的是G++编译器,和普通使用的TC,VC都有所不同,建议大家使用Dev C++作为IDE,或者用TC和VC写代码,提交前使用Dev C++编译,预防编译错误。
提交C语言代码最好使用G++,G++兼容C和C++。C的代码可以用GCC也可用G++提交,而C++的代码不能够用GCC提交,只能用G++。
(more…)
Tag: acm
-
如何避免由于编译器差别带来的错误
-
poj_1009(TLE&MLE)
/* //ACM Poj 1009 //File: 1009.cpp //Author: Kangzj //Mail: Kangzj@mail.bnu.edu.cn //Date: April 29, 2009 */ #include
#include #include #include -
poj_1008
/* //ACM Poj 1008 //File: 1008.cpp //Author: Kangzj //Mail: Kangzj@mail.bnu.edu.cn //Date: April 29, 2009 */ #include
#include using namespace std; struct TYD { int Dnum; string Dname; }; int main() { string TkDays[20]={"imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"}; string HbMons[19]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu"}; ostringstream buff; TYD Tday; int i,j,n; int Hyear,Hday, Tyear; string Hdaystr, Hmonth; int days,Tdays; cin>>n; buff< >Hdaystr>>Hmonth>>Hyear; Hdaystr=Hdaystr.substr(0,Hdaystr.size()-1); if (Hdaystr.size()==2) { Hday=(Hdaystr[0]-'0')*10+(Hdaystr[1]-'0'); }else { Hday=(Hdaystr[0]-'0'); } if(Hmonth=="uayet") { j=18; } else { for(j=0;j<18;j++) { if(Hmonth==HbMons[j]) { break; } } } days=Hyear*365+j*20+Hday; Tyear=days/260; Tdays=days%260;//注意边界! Tday.Dname=TkDays[Tdays%20]; Tday.Dnum=Tdays%13+1; buff< -
poj_1007
/* //ACM Poj 1007 //File: 1007.cpp //Author: Kangzj //Mail: Kangzj@mail.bnu.edu.cn //Date: April 28, 2009 */ #include
#include using namespace std; struct revNum { int rvNums; int order; }; int getReverseNum(string DNA, int n) { int *count=new int[n]; int all=0,i; for (i=0;i =0;i--) { for(int j=0;j>n>>m; string *DNA=new string[m]; int count=0,temp,i; revNum *rvNum=new revNum[m]; for(i=0;i >DNA[i]; temp=getReverseNum(DNA[i],n); //插入排序 if(count==0) { rvNum[0].rvNums=temp; rvNum[0].order=i; count++; } else { int j,flag=0; for(j=0;j j;k--) { rvNum[k]=rvNum[k-1]; } rvNum[j].rvNums=temp; rvNum[j].order=i; count++; flag=1; break; } }//for(int j=0;j -
poj_1005
/* //ACM Poj 1005 //File: 1005.cpp //Author: Kangzj //Mail: Kangzj@mail.bnu.edu.cn //Date: April 28, 2009 */ #include
#include -
poj_2000
/* //ACM Poj 2000 //File: 2000.cpp //Author: Kangzj //Mail: Kangzj@mail.bnu.edu.cn //Date: April 24, 2009 */ #include
#include #include -
zoj_1002(Fire Net)的一个简单的解法
做了一天,把此题AC了,看到网上用的算法很复杂,发个自己的出来。
思路:
1.如果城市全空,可以不管顺序,随便从哪里开始放“碉堡”,把“碉堡”射程里的城市标记下,后面的“碉堡”不放在这里即可得到结果。
2.但是如果城市中有“墙”的话,就不可以按照1的方法了,因为放置数量的多少与顺序是有关的,所以,怎样来确定这个顺序是很重要的。观察发现,城市里的空地按照领域中的“墙”的数量可以分为五种,即从0到4。再观察,可以得到这样一个结论:按邻域中墙的数目由多到少,往空地上安放“碉堡”,可以使数目最大!
于是按照这个结论,编程如下:
(more…) -
poj_1006
Problem: http://poj.grids.cn/problem?id=1006
Solution:
#include
#include #include using namespace std; int main() { int p, e, i, n=0; long cp, ce, ci; short d; int j=1;//计数用 ostringstream buf; while(1) { cin>>p>>e>>i>>d; if(p==-1 && e==-1 && i==-1 && d==-1) { break; } n=d; while(1) { n++; if((n-p)%23==0 && (n-e)%28==0 && (n-i)%33==0) { n-=d; if(n==0) { n=d; continue; } break; } //cout< <"*"; } buf<<"Case "< -
poj_1004
#include
using namespace std; int main() { int i; float all=0, temp=0; for(i=0;i<12;i++) { cin>>temp; all+=temp; } all+=0.005; cout.precision(2); //cout.setf(ios_base::showpoint); cout< <"$"<
