一名大三older 希望能帮助大一萌新。。。加油 xiandianer!!!!;
xdoj 1260 (B) 水题 用了一下STL (好长啊。。。)
#include<iostream> #include<cstdio> #include<algorithm> #include<map> using namespace std; const int N=107; struct T{ string suj; double p; bool operator <(const T& b) const { return suj<b.suj; } }; map <T,int> mapp; int n; double f (int x) { if (x<=59) return 0.0; if (x<=62) return 1.0; if (x<=65) return 1.5; if (x<=68) return 1.7; if (x<=71) return 2.0; if (x<=74) return 2.3; if (x<=77) return 2.7; if (x<=81) return 3.0; if (x<=84) return 3.3; if (x<=89) return 3.7; return 4.0; } int main () { cin>>n; map<T,int>::iterator it; for (int i=1;i<=n;i++) { T temp; int w; cin>>temp.suj>>temp.p>>w; if (mapp[temp]<w) mapp[temp]=w; } it=mapp.begin(); double sum=0.0; double k=0.0; double nn=0.0; while (it!=mapp.end()) { sum+=(it->first.p)*(it->second); k+=(it->first.p)*f(it->second); nn+=it->first.p; it++; } printf ("%.1lf %.2lf ",sum/nn,k/nn); return 0; }
xdoj 1255 (C) 水题 不明白为什么不加getchar() 会GG;
#include<iostream> #include<cstdio> #include<string> using namespace std; char* str="0123456789ABCDEF"; int main () { int x,y,z; while (~scanf("(%d, %d, %d)",&x,&y,&z)) { char s[7]; s[0]=str[x/16]; s[1]=str[x%16]; s[2]=str[y/16]; s[3]=str[y%16]; s[4]=str[z/16]; s[5]=str[z%16]; s[6]='