SPOJ
spotboy
记录我的学习,研究计算机科学与技术的点滴。
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
SPOJ BYTESM2
#include #include using namespace std;const int N = 100;int tiles[N][N];int sums[N][N];int r,c;int totalsum;void computeMax(int i, int j) { int s1, s2, s3; if (j == 0) { s1 = -1; } els原创 2014-05-14 22:44:46 · 642 阅读 · 0 评论 -
SPOJ HUBULLU
// http://www.spoj.com/problems/HUBULLU/// Because 1 is all numbers’ divisor. // So, the first people can choose ‘1’ with all other numbers.#include using namespace std;void f() { int n; cin >原创 2014-02-06 16:28:40 · 1050 阅读 · 0 评论 -
SPOJ NGM
// http://www.spoj.com/problems/NGM//* Win/Lost Table1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20W W W W W W W W W L W W W W W W W W W LSo seems postition X0 can be lose for Nik*原创 2014-01-28 23:12:53 · 538 阅读 · 0 评论 -
SPOJ STAMPS
// http://www.spoj.com/problems/STAMPS/#include #include using namespace std;int main() { ios_base::sync_with_stdio(false); int t; cin >> t; int s = 1; while (t-- >0) { int target, np;原创 2014-01-25 22:18:06 · 534 阅读 · 0 评论 -
SPOJ WILLITST
// http://www.spoj.com/problems/WILLITST/#include using namespace std;int main() { unsigned long long int t; cin >> t; if((t&(t-1))==0) //checks for 2^n cout << "TAK" << endl; else原创 2014-01-26 17:41:32 · 501 阅读 · 0 评论 -
SPOJ PT07Y
// http://www.spoj.com/problems/PT07Y/#include using namespace std;int findroot(int* points, int p) { while (points[p] != p) p = points[p]; return p;}int main() { int V, E; cin >> V >> E; in原创 2014-01-28 14:00:41 · 776 阅读 · 0 评论 -
SPOJ OFFSIDE
// http://www.spoj.com/problems/OFFSIDE/#include #include #include using namespace std;int main(){ int a, d; cin >> a >> d; vector A; vector D; while (a != 0 && d != 0) { int t; for (in原创 2014-01-28 14:53:19 · 748 阅读 · 0 评论 -
SPOJ AP2
// http://www.spoj.com/problems/AP2/#include #include using namespace std;int main() { ios_base::sync_with_stdio(false); int t; cin >> t; while (t-- >0) { long long thirdt = 0; long long原创 2014-01-29 10:02:44 · 606 阅读 · 0 评论 -
SPOJ STPAR
// http://www.spoj.com/problems/STPAR/#include #include using namespace std;int main() { ios_base::sync_with_stdio(false); int num = 0; cin >> num; const int NOTSET = -1; stack waitting;原创 2014-01-26 14:58:19 · 668 阅读 · 0 评论 -
SPOJ BITMAP
// http://www.spoj.com/status/BITMAP,lojian/#include #include using namespace std;int f(){ int n,m; char c; cin >> n >> m; short int tab[n][m]; queue Q; for(int i=0; i<原创 2014-02-06 13:57:48 · 554 阅读 · 0 评论 -
SPOJ ARITH2
//http://www.spoj.com/problems/ARITH2/#include #include #include using namespace std;int main() { int t; cin >> t; queue numbers; queue operations; long result = 0; bool first = true; whil原创 2014-01-30 00:28:59 · 497 阅读 · 0 评论 -
SPOJ BEENUMS
// http://www.spoj.com/problems/BEENUMS/#include using namespace std;int main() { long cells; cin >> cells; while (cells != -1) { if (cells == 1) { cout << "Y" << endl; } else { int c原创 2014-01-29 23:46:35 · 472 阅读 · 0 评论 -
SPOJ Alphacode
// http://www.spoj.com/problems/ACODE/#include #include #include using namespace std;const int maxn = 50000 + 10;int n;char s[ maxn ];long long f[ maxn ];void work()原创 2014-01-15 22:56:58 · 559 阅读 · 0 评论 -
SPOJ MAXLN
// http://www.spoj.com/problems/MAXLN/#include #include using namespace std;void f(int casenum) { int r; double c = 0.25; cin >> r; double result = 4.0f * (double)r * (double)r + c; cout << "原创 2014-02-11 00:47:02 · 591 阅读 · 0 评论 -
SPOJ ARMY
// http://www.spoj.com/problems/ARMY/#include #include #include #include using namespace std;int main(int argc, char*argv[]) { ios_base::sync_with_stdio(false); int t; cin >> t; string原创 2014-01-25 21:39:31 · 460 阅读 · 0 评论 -
SPOJ PIGBANK
// http://www.spoj.com/problems/PIGBANK/#include#include#includeusing namespace std;#define Max 10000// dp(x) means the minimal value of conins with weight x.int dp[Max+1];// temp(x) means原创 2014-02-11 00:49:52 · 592 阅读 · 0 评论 -
SPOJ MARBLES
// http://www.spoj.com/problems/MARBLES/#include using namespace std;// 假设30个位置void f() { int n, k; cin >> n >> k; long double result; n--; k--; result = 1.0; for(double i=0.0; i<k; i+=1.0原创 2014-02-11 00:49:17 · 524 阅读 · 0 评论 -
SPOJ PALIN
// http://www.spoj.com/problems/PALIN/#include #include int main(){ int t,len,l,m,r,c,cur; char K[1000001],tmp[1000001]; scanf("%d",&t); while(t--) { memset(K,0,sizeof(K)); memset(tmp,0原创 2014-02-07 00:10:31 · 534 阅读 · 0 评论 -
SPOJ FENCE1
// http://www.spoj.com/problems/FENCE1/#include #include using namespace std;/*L = PI * R;R = L/PI;S = PI * (L/PI)^2 /2 = L^2/PI/2*/const float PI = 3.1415926f;int main() { ios_base::sync原创 2014-01-26 15:28:35 · 555 阅读 · 0 评论 -
SPOJ GIRLSNBS
// http://www.spoj.com/problems/GIRLSNBS/#include #include using namespace std;int main(){ int g, b; cin >> g >> b; while (g != -1 && b != -1) { int bigger, smaller; if (g > b) { bigge原创 2014-01-28 17:36:28 · 1004 阅读 · 0 评论 -
SPOJ INVCNT
// http://www.spoj.com/problems/INVCNT/#include using namespace std;long long mergeCount(int a[], int low, int mid, int high) { int b[200000]; int i = low; int j = mid + 1; int k = low; long原创 2014-02-06 13:58:18 · 545 阅读 · 0 评论 -
Ambiguous Permutations
//http://www.spoj.com/problems/PERMUT2/#include using namespace std;int main(int argc, char* argv[]) { int buffer[100001]; int n; cin >> n; while (n!=0) { for (int i = 1; i <=n; i++) { c原创 2014-01-15 22:10:00 · 731 阅读 · 0 评论 -
Factorial
// http://www.spoj.com/problems/FCTRL/#include #include int main(int argc, char* argv[]){ using std::cin; using std::cout; int c = 0; cin >> c; while (c-- >0) { int n; cin >> n; int a原创 2014-01-12 06:15:13 · 665 阅读 · 0 评论 -
To and Fro
// http://www.spoj.com/problems/TOANDFRO/#include #include #include using std::cin;using std::cout;using std::endl;using std::string;using std::memset;int main(int argc, char* argv[]) { int原创 2014-01-12 10:42:52 · 536 阅读 · 0 评论 -
Julka
// http://www.spoj.com/problems/JULKA/// hint: x+y=total x-y=diff x = (total+diff)/2; y = total -x;#include #include #include #include #include #include #include #include #include #inclu原创 2014-01-12 14:47:03 · 574 阅读 · 0 评论 -
Fashion Shows
// http://www.spoj.com/problems/FASHION/#include #include using namespace std;int compare_ints(const void* a, const void* b) { int arg1 = *reinterpret_cast(a); int arg2 = *reinterpret_cast(b);原创 2014-01-12 15:30:23 · 531 阅读 · 0 评论 -
What’s Next
// http://www.spoj.com/problems/ACPC10A/#include using namespace std;int main(int argc, char* argv[]) { int a, b, c; cin >> a >> b >> c; while(a != b && b != c && c != a) { int diffba = b -原创 2014-01-12 16:09:07 · 530 阅读 · 0 评论 -
Small factorials
// http://www.spoj.com/problems/FCTRL2/#include #include using std::cin;using std::cout;using std::endl;unsigned long long calFactorial(int n){ unsigned long long result=1; for(unsigned lon原创 2014-01-12 06:13:55 · 526 阅读 · 0 评论 -
Adding Reversed Numbers
// http://www.spoj.com/problems/ADDREV/#include #include #include #include int main(int argc, char* argv[]){ using std::string; using std::reverse; int N = 0; std::cin >> N; while ( N原创 2014-01-12 06:16:14 · 631 阅读 · 0 评论 -
Prime Generator
// http://www.spoj.com/problems/PRIME1/#include #include #include #include using namespace std;int main(){ int casen; cin >> casen; while(casen--) { int n,m;原创 2014-01-12 06:10:56 · 583 阅读 · 0 评论 -
Number Steps
// http://www.spoj.com/problems/NSTEPS/#include using std::cin;using std::cout;using std::endl;int main(int argc, char* argv[]) { int testnum; cin >> testnum; while (testnum-- > 0) { int x原创 2014-01-12 06:05:46 · 668 阅读 · 0 评论 -
Feynman
// http://www.spoj.com/problems/SAMER08F/#include using std::cin;using std::cout;using std::endl;int solve(int n) { int total = 0; if (n == 1) { total = 1; } else { total = 0; for (原创 2014-01-12 06:07:25 · 643 阅读 · 0 评论 -
Candy I
// http://www.spoj.com/problems/CANDY/#include using namespace std;int main(int argc, char* argv[]) {int n;cin >> n;while(n!=-1) {int *p = new int[n];int total = 0;int av原创 2014-01-12 15:56:03 · 573 阅读 · 0 评论 -
Anti-Blot System
// http://www.spoj.com/problems/ABSYS/#include #include #include #include #include using namespace std;int main(int argc, char* argv[]) { int t; cin >> t; string line; std::getline(std::原创 2014-01-14 23:09:03 · 725 阅读 · 0 评论 -
Count on Cantor
// http://www.spoj.com/problems/CANTON/#include using namespace std;int main(int argc, char* argv[]) { int t; cin >> t; while (t-- >0) { int n; cin >> n; int approacher = 1; int x = 1;原创 2014-01-14 22:30:31 · 588 阅读 · 0 评论 -
Triple Fat Ladies
// http://www.spoj.com/problems/EIGHTS/#include using namespace std;int main(int argc, char* argv[]) { int t; cin >> t; while (t-- >0) { long long k; cin >> k; cout << (192ll + (k -1ll)*原创 2014-01-13 22:02:25 · 648 阅读 · 0 评论 -
Hangover
// http://www.spoj.com/problems/HANGOVER/#include using namespace std;int main(int argc, char* argv[]) { float testcase; cin >> testcase; while (testcase != 0.00f) { float a = 2.0f; floa原创 2014-01-13 21:44:34 · 499 阅读 · 0 评论 -
The last digit
// http://www.spoj.com/problems/LASTDIG/#include using namespace std;int dat[10][4]={{0,0,0,0}, {1,1,1,1}, {2,4,8,6}, {3,9,7,1}, {4,6,4,6}, {5,5,5,5}, {6,6,6,6},原创 2014-01-12 21:51:55 · 611 阅读 · 0 评论 -
Rectangles
//http://www.spoj.com/problems/AE00/#include #include using namespace std;int main(int argc, char* argv[]) { int n; cin >> n; int sum = 0; for (int i = 1; i <=n; i++) { for (int w=1; w*w<=i原创 2014-01-12 21:15:34 · 535 阅读 · 0 评论 -
Bytelandian gold coins
//http://www.spoj.com/problems/COINS/#include #include using namespace std;#define MEMOSIZE 1000000unsigned memo[MEMOSIZE];unsigned maxprofit(unsigned n) { unsigned s; if ((n<MEMOSIZE)&&memo[原创 2014-01-12 22:10:16 · 917 阅读 · 0 评论
分享