int process ( ifstream & ifile, ofstream & log, earthquake & EQ ) { stringstream str, str2; str.precision ( 3 ); str << "# " << EQ.get_day () << " " << EQ.get_month_str () << " " << EQ.get_year () << " " << setfill ('0') << setw ( 2 ) << EQ.get_hour () << ":" << setfill ( '0' ) << setw ( 2 ) << EQ.get_min () << ":" << setfill ( '0' ) << setw ( 2 ) << EQ.get_sec () << '.' << setfill( '0' ) << setw ( 3 ) << setprecision ( 0 ) << fixed << EQ.get_ms () << " " << EQ.tz << " " << EQ.get_magnitude_Type_str () << " " << fixed << setprecision ( 1 ) << EQ.get_magnitude () << " " << EQ.earthquake_name << " [" << EQ.id << "] (" << setprecision ( 2 ) << fixed << EQ.get_lon () << ", " << fixed << EQ.get_lat () << ", " << setprecision ( 1 ) << EQ.get_elv () << ")" << endl; EQ.sign = 0; for ( int i = 0; i < EQ.valid; i++ ) { string s = EQ.stations[i].get_orientation(); unsigned int n = s.size(); for ( size_t j = 0; j < n; j++ ) { str2 << EQ.id << '.' << EQ.stations[i].get_network_code_str () << '.' << EQ.stations[i].get_station_name () << '.' << EQ.stations[i].get_type_of_band_str () << EQ.stations[i].get_type_of_instrument_str () << s[j] << endl; EQ.sign++; } } str << EQ.sign << endl; print ( log, str, true ); print ( log, str2, true ); return 0; }
int main() { ios_base::sync_with_stdio(0); cout.precision(output_precision); cout << fixed; ss.precision(output_precision); ss << fixed; cin >> N >> X0 >> Y0 >> C; if (C == 1) { cout << 0 << endl; return 0; } else { ll bad = 0; ll good = N*2; while (bad+1<good) { ll s = (good+bad)>>1; ll sum = 0; sum += f(s,X0,Y0); sum += f(s,X0,N-Y0+1); sum += f(s,N-X0+1,Y0); sum += f(s,N-X0+1,N-Y0+1); sum -= min(N-X0+1, s+1); sum -= min(N-Y0+1, s+1); sum -= min(X0, s+1); sum -= min(Y0, s+1); sum++; assert(sum >= 0); if (sum < C) bad = s; else good = s; } cout << good << endl; return 0; } }
int main() { ios_base::sync_with_stdio(0); cout.precision(output_precision); cout << fixed; ss.precision(output_precision); ss << fixed; cin >> N >> Q; segTree st; st.init(N); rep1(i,N) st.add(i,1); // rep1(i,N) db(st.query(i,i)); // rep1(i,N) st.add(i,1); // rep1(i,N) db(st.query(i,N)); int leftMost = 1; vector<int> ans; // st.print(leftMost); rep1(q,Q) { int t, p, l, r; cin >> t; switch(t) { case 1: cin >> p; rep1(k,p) st.add(leftMost+2*p-k,st.query(leftMost+k-1,leftMost+k-1)); leftMost += p; // st.print(leftMost); break; case 2: cin >> l >> r; ans.pb(st.query(leftMost+l, leftMost+r-1)); break; } }
int main() { ios_base::sync_with_stdio(0); cout.precision(output_precision); cout << fixed; ss.precision(output_precision); ss << fixed; set<int> st; rep1(i, 100) st.insert(i); }
int main() { ios_base::sync_with_stdio(0); cout.precision(output_precision); cout << fixed; ss.precision(output_precision); ss << fixed; cin >> N >> M >> K; rep1(i,M) { cin >> X[i]; }
// Print the minimum value of 'dtype' void dtype_min(bh_type dtype, stringstream &out) { if (bh_type_is_integer(dtype)) { out << bh_type_limit_min_integer(dtype); } else { out.precision(std::numeric_limits<double>::max_digits10); out << bh_type_limit_min_float(dtype); } }
int main() { ios_base::sync_with_stdio(0); cout.precision(output_precision); cout << fixed; ss.precision(output_precision); ss << fixed; __gcd(0,3); }
int main() { ios_base::sync_with_stdio(0); cout.precision(output_precision); cout << fixed; ss.precision(output_precision); ss << fixed; cin >> N; rep1(i,N) { cin >> s[i]; s[i] = " " + s[i] + " "; }
int main() { ios_base::sync_with_stdio(0); cout.precision(output_precision); cout << fixed; ss.precision(output_precision); ss << fixed; cin >> N; rep1(i,N) { cin >> A[i]; inv[A[i]]=i; }
int main() { ios_base::sync_with_stdio(0); cout.precision(output_precision); cout << fixed; ss.precision(output_precision); ss << fixed; cin >> s; N = s.size(); s = " " + s; // db(s[N]-'0'); // rep1(i, N) db(s[i]); cout << dp(N, 0) << endl; }
int main() { ios_base::sync_with_stdio(0); cout.precision(output_precision); cout << fixed; ss.precision(output_precision); ss << fixed; cin >> N; rep1(i,N) { int foo; cin >> foo; mx = max(foo,mx); }
// Print the maximum value of 'dtype' void dtype_max(bh_type dtype, stringstream &out) { if (bh_type_is_integer(dtype)) { out << bh_type_limit_max_integer(dtype); if (not bh_type_is_signed_integer(dtype)) { out << "u"; } } else { out.precision(std::numeric_limits<double>::max_digits10); out << bh_type_limit_max_float(dtype); } }
int main() { ios_base::sync_with_stdio(0); cout.precision(output_precision); cout << fixed; ss.precision(output_precision); ss << fixed; cin >> N; rep1(i, N) { int foo, bar; cin >> foo >> bar; ans |= foo!=bar; }
int main() { ios_base::sync_with_stdio(0); cout.precision(output_precision); cout << fixed; ss.precision(output_precision); ss << fixed; #ifdef LOCAL_TEST debug = true; #endif cin >> s; ll n; if (s.size() <= 10) { ss << s; ss >> n; }
int main() { ios_base::sync_with_stdio(0); cout.precision(output_precision); cout << fixed; ss.precision(output_precision); ss << fixed; int A, B, C, original; cin >> A >> B; C = A+B; original = C; stack<int> stk; while (A) { stk.push(A%10); A/=10; } while (!stk.empty()) { if (stk.top()!=0) A = 10*A+stk.top(); stk.pop(); } while (B) { stk.push(B%10); B/=10; } while (!stk.empty()) { if (stk.top()!=0) B = 10*B+stk.top(); stk.pop(); } while (C) { stk.push(C%10); C/=10; } while (!stk.empty()) { if (stk.top()!=0) C = 10*C+stk.top(); stk.pop(); } // db(A); db(B); db(C); if (A+B==C) cout <<"YES" << endl; else cout << "NO" << endl; }
void SexpParser::ListToString(stringstream& ss, const ParameterList& lst) { string space; ss.setf(ios_base::fixed,ios_base::floatfield); ss.precision(2); for ( ParameterList::TVector::const_iterator i = lst.begin(); i != lst.end(); ++i ) { if (i->type() == typeid(string)) { ss << space; ss << boost::any_cast<string>(*i); } else if (i->type() == typeid(float)) { ss << space; ss << boost::any_cast<float>(*i); } else if (i->type() == typeid(int)) { ss << space; ss <<boost::any_cast<int>(*i); } else if (i->type() == typeid(ParameterList)) { const any* v = &(*i); const ParameterList* lst = any_cast<ParameterList>(v); ss << space; ss << '('; ListToString(ss,*lst); ss << ')'; } else { ss << space; ss << "(error data format unknown)"; } space = " "; } }
int main() { ios_base::sync_with_stdio(0); cout.precision(output_precision); cout << fixed; ss.precision(output_precision); ss << fixed; cin >> N; rep1(i, N) { cin >> s; if (s.size() <= 10) ss << s << endl; else { ss << s[0]; ss << (s.size()-2); ss << s[s.size()-1] << endl; } }
int main() { ios_base::sync_with_stdio(0); cout.precision(output_precision); cout << fixed; ss.precision(output_precision); ss << fixed; cin >> N >> K >> T; int ub = T*N*K; rep1(i, N) { while (A[i] < K && cur + 100 <= ub) { A[i]++; cur += 100; } } rep1(i, N) cout << A[i] << (i==N ? "\n" : " "); }
int main() { ios_base::sync_with_stdio(0); cout.precision(output_precision); cout << fixed; ss.precision(output_precision); ss << fixed; int Y, K, N; cin >> Y >> K >> N; int X = (((-Y)%K)+K)%K; // db(X); db(Y); db(K); db(N); vector<int> ans; ans.clear(); while (X+Y<=N) { // db(X); if (X > 0) ans.pb(X); X += K; } if (ans.empty()) cout << -1 << endl; else rep(i, ans.size()) cout << ans[i] << (i == ans.size()-1 ? '\n' : ' '); }
int main() { ios_base::sync_with_stdio(0); cout.precision(output_precision); cout << fixed; ss.precision(output_precision); ss << fixed; ld y1, y2, yw, xb, yb, r; cin >> y1 >> y2 >> yw >> xb >> yb >> r; ld y11 = yw*2 - y1; ld y22 = yw*2 - y2; ld Y = (y11 + y22) / 2; ld YY = Y - yb; ld Z = sqrt(YY*YY+xb*xb); ld s = r*Z/xb; if (Y-s > y22) { ld a = (yb - Y) / xb; ld b = Y; ld XX = (yw - r - b) / a; cout << XX << endl; } else { cout << -1 << endl; } // y1 = yw + yw - y1; // y2 = yw + yw - y2; // ld y = (y1+y2)/2 - yb; // ld yy = y - (sqrt(y*y+xb*xb)*r/xb); // if (yy >= y2) // { // ld a = y / xb; // ld b = y + yb; // cout << (yw - b)/a << endl; // // } // else // { // cout << -1 << endl; // } }
int main() { ios_base::sync_with_stdio(0); cout.precision(output_precision); cout << fixed; ss.precision(output_precision); ss << fixed; cin >> N >> K >> D; ld cur = N; rep1(i, D) { cur /= K; } if (cur > 1) { cout << -1 << endl; return 0; } rep1(student, N) { ll cur = 1; rep1(day, D) { ans[student][day]=(((student-1)/cur)%K)+1; if (cur<INF) cur *= K; }
void ReplSetImpl::_getOplogDiagsAsHtml(unsigned server_id, stringstream& ss) const { const Member *m = findById(server_id); if( m == 0 ) { ss << "Error : can't find a member with id: " << server_id << '\n'; return; } ss << p("Server : " + m->fullName() + "<br>ns : " + rsoplog ); //const bo fields = BSON( "o" << false << "o2" << false ); const bo fields; /** todo fix we might want an so timeout here */ DBClientConnection conn(false, 0, /*timeout*/ 20); { string errmsg; if( !conn.connect(m->fullName(), errmsg) ) { ss << "couldn't connect to " << m->fullName() << ' ' << errmsg; return; } } auto_ptr<DBClientCursor> c = conn.query(rsoplog, Query().sort("$natural",1), 20, 0, &fields); if( c.get() == 0 ) { ss << "couldn't query " << rsoplog; return; } static const char *h[] = {"ts","optime", "h","op","ns","rest",0}; ss << "<style type=\"text/css\" media=\"screen\">" "table { font-size:75% }\n" // "th { background-color:#bbb; color:#000 }\n" // "td,th { padding:.25em }\n" "</style>\n"; ss << table(h, true); //ss << "<pre>\n"; int n = 0; // we save ts as a timestamp, so even though we don't really // use OpTimes anymore, this code is fine OpTime otFirst; OpTime otLast; OpTime otEnd; while( c->more() ) { bo o = c->next(); otLast = o["ts"]._opTime(); if( otFirst.isNull() ) otFirst = otLast; say(ss, o); n++; } if( n == 0 ) { ss << rsoplog << " is empty\n"; } else { auto_ptr<DBClientCursor> c = conn.query(rsoplog, Query().sort("$natural",-1), 20, 0, &fields); if( c.get() == 0 ) { ss << "couldn't query [2] " << rsoplog; return; } string x; bo o = c->next(); otEnd = o["ts"]._opTime(); while( 1 ) { stringstream z; if( o["ts"]._opTime() == otLast ) break; say(z, o); x = z.str() + x; if( !c->more() ) break; o = c->next(); } if( !x.empty() ) { ss << "<tr><td>...</td><td>...</td><td>...</td><td>...</td><td>...</td></tr>\n" << x; //ss << "\n...\n\n" << x; } } ss << _table(); ss << p(time_t_to_String_short(time(0)) + " current time"); if( !otEnd.isNull() ) { ss << "<p>Log length in time: "; unsigned d = otEnd.getSecs() - otFirst.getSecs(); double h = d / 3600.0; ss.precision(3); if( h < 72 ) ss << h << " hours"; else ss << h / 24.0 << " days"; ss << "</p>\n"; } }
void PrintLatexStats(ImageBuffer *imgbuf, Scene *scene) { int numleaves = 0; for(int i=0; i < scene->nkdjobs; i++) { numleaves += scene->kdjob[i].curleaf; } unsigned opt_rendertime = scene->transform_time + scene->kdbuild_time; opt_rendertime += scene->raygen_time + scene->kdtravers_time; opt_rendertime += scene->polypartition_time + scene->polytest_time + scene->raster_time; if(args.printstats && (firstframe || GetScene()->animate) && frame < 25 && frame > 0) { int apt; if(scene->nleafhits > 0) apt = (scene->npolytests)/scene->nleafhits; else apt = 0; int als = KDGetNumLeafPolys()/numleaves; int fhp; if(scene->nfrustums > 0) fhp = (scene->nfrustumhits*100) / scene->nfrustums; else fhp = 0; float aep; if(scene->nfrustumhits > 0) aep = (float)scene->total_frustum_dep / (float)scene->nfrustumhits; else aep = 0; if(frame == 1) { file.open("stats.tex", ios::trunc); file << "\\documentclass{article}" << endl; file << "\\usepackage{multirow}" << endl; file << "\\usepackage{a4}" << endl; file << "\\usepackage[danish]{babel}" << endl; file << "\\usepackage[utf8]{inputenc}" << endl; file << "\\usepackage{verbatim}" << endl; file << "\\begin{document}" << endl; file << "\\subsection{" << args.luascript << " " << ARCH_STR << " " << (args.renderer == R_GENERIC ? "Generic" : "Cell") << "}" << endl; file << "\\scriptsize" << endl; file << "\\subsubsection{Parametre}" << endl; file << "\\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|} \\hline" << endl; file << "NT & NRJ & SR & RR & MLS & ED & NEP & NEA & FD & FSS & FNS \\\\ \\hline" << endl; file << args.nthreads << " & " << args.njobs << " & "; file << (scene->shadowrays ? "On" : "Off") << " & "; file << (scene->secondrays ? "On" : "Off") << " & "; file << scene->kdtree_mls << " & " << scene->kdtree_etd << " & "; file << KDGetNumberOfSplits() << " & " << KDGetNumberOfAxises() << " & "; file << scene->frustumdim << " & " << scene->frustumstepsize << " & " << scene->frustumstep; file << "\\\\ \\hline" << endl; file << endl; file << "\\hline" << endl; file << "\\end{tabular}" << endl; file << "\\subsubsection{Målinger}" << endl; file << "\\begin{tabular}{|l|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|} \\hline " << endl; file << " & FPS & MPT & TUP & ALS & LHP & LPR & APT & FHP & DEP & AEP \\\\ \\hline" << endl; kernel_stats << "\\begin{tabular}{|l|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|} \\hline \n"; kernel_stats << " & Transform & KDBuild & RayGen & Travers & PolyPartition & PolyTest & Total \\\\ \\hline \n"; } file.precision(2); file << "Frame " << frame << " & "; file << (float)(1000.0f) / (float)(rendertime) << " & "; file << (scene->npolytests)/ 1000000.0f << " & "; file << opt_rendertime*100 / rendertime << "\\% & "; file << als << " & "; file << (scene->nleafhits*100)/ ( imgbuf->GetWidth() * imgbuf->GetHeight()) << "\\% & "; file << (float)apt/(float)als << " & "; file << apt << " & "; file << fhp << "\\% & "; file << scene->frustum_dep << " & ";printf("Total\n"); printf("\tThreads: %i\n", args.nthreads); printf("\tJobs : %i\n\n", args.njobs); printf("\tFPS : %.2f - %.2f\n", stats.min_fps, stats.max_fps); printf("\tMPT : %.2f - %.2f\n", stats.min_mpt, stats.max_mpt); printf("\tTUP : %g%% - %g%%\n", stats.min_tup, stats.max_tup); printf("\tALS : %i - %i\n", stats.min_als, stats.max_als); printf("\tLHP : %i%% - %i%%\n", stats.min_lhp, stats.max_lhp); printf("\tLPR : %.2g - %.2g\n", stats.min_lpr, stats.max_lpr); printf("\tAPT : %i - %i\n", stats.min_apt, stats.max_apt); printf("\tFHP : %i%% - %i%%\n", stats.min_fhp, stats.max_fhp); printf("\tDEP : %i - %i\n", stats.min_dep, stats.max_dep); printf("\tAEP : %.2g - %.2g\n\n", stats.min_aep, stats.max_aep); printf("\tTT : %i - %i ms\n", stats.min_tt, stats.max_tt); printf("\tKDB : %i - %i ms\n", stats.min_kdb, stats.max_kdb); printf("\tRG : %i - %i ms\n", stats.min_rg, stats.max_rg); printf("\tKDT : %i - %i ms\n", stats.min_kdt, stats.max_kdt); printf("\tPP : %i - %i ms\n", stats.min_pp, stats.max_pp); printf("\tPT : %i - %i ms\n", stats.min_pt, stats.max_pt); file << aep; file << "\\\\ \\hline" << endl; if(frame > 0) { kernel_stats.precision(2); kernel_stats << "Frame " << frame << " & "; kernel_stats << scene->transform_time << " ms & "; kernel_stats << scene->kdbuild_time << " ms & "; kernel_stats << scene->raygen_time << " ms & "; kernel_stats << scene->kdtravers_time << " ms & "; kernel_stats << scene->polypartition_time << " ms & "; kernel_stats << scene->polytest_time << " ms & "; kernel_stats << (scene->transform_time + scene->kdbuild_time + scene->raygen_time + scene->kdtravers_time + scene->polypartition_time + scene->polytest_time) << " ms "; kernel_stats << " \\\\ \\hline\n"; } } if(args.printstats && frame == 25) { file << "\\end{tabular}" << endl; kernel_stats << "\\end{tabular} \n"; file << "\\\\ \\ \\\\ \\ \\\\ \\ \\\\\n" << kernel_stats.str(); file << "\\normalsize" << endl; file << "\\end{document}" << endl; file.close(); cout << "Done writing stats.tex" << endl; } }