Skip to content

Instantly share code, notes, and snippets.

View ititorit's full-sized avatar

Nguyễn Minh Tuấn ititorit

View GitHub Profile
@ititorit
ititorit / ROUD1APROA.cpp
Last active September 20, 2016 22:22
SPOJ ROUND 1A - Số gần nguyên tố
#include <bits/stdc++.h>
#define _for(i,a,b) for(int i=(a),_b_=(b),_d_=(a<b?1:-1);i!=_b_;i+=_d_)
#define FOR(i,a,b) for(int i = a; i <= b; i++)
#define _it(i,v) for (typeof((v).begin()) i = (v).begin(); i != (v).end(); ++i)
#define _all(v) v.begin(), v.end()
#define DEBUG(x) { cout << #x << " = " << x << endl; }
#define sqr(x) ((x)*(x))
@ititorit
ititorit / LIS.cpp
Created September 20, 2016 22:23
SPOJ LIS
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define FORD(i, a, b) for(int i = a; i < b; i++)
#define REP(i, a, b) for(int i = a; i >= b; i--)
#define REPD(i, a, b) for(int i = a; i > b; i--)
#define DEBUG(x) { cout << #x << " = " << x << endl; }
@ititorit
ititorit / SUBSTR.cpp
Last active September 20, 2016 23:37
SPOJ SUBSTR
// contest: http://vn.spoj.com/problems/SUBSTR/
// author: Nguyễn Minh Tuấn
// Đại Học Khoa Học Huế.
//->>>>>>>> Đặc biết chú ý: Bài này, mình sử dụng thuật toán KMP(Thuật toán Knuth–Morris–Pratt) để giải.. các bạn có thể tham
// khảo.
#include <bits/stdc++.h>
@ititorit
ititorit / CPTTRN1.cpp
Last active September 22, 2016 15:03
SPOJ CPTTRN1
// contest: http://www.spoj.com/problems/CPTTRN1/
// author: Nguyen Minh Tuan.
// Language: C/C++.
#include <bits/stdc++.h>
#define _for(i,a,b) for(int i=(a),_b_=(b),_d_=(a<b?1:-1);i!=_b_;i+=_d_)
#define FOR(i,a,b) for(int i = a; i <= b; i++)
#define _it(i,v) for (typeof((v).begin()) i = (v).begin(); i != (v).end(); ++i)
#define _all(v) v.begin(), v.end()
@ititorit
ititorit / CPTTRN2.cpp
Created September 22, 2016 15:05
SPOJ CPTTRN2
// contest: http://www.spoj.com/problems/CPTTRN2/
// author: Nguyen Minh Tuan.
// Language: C/C++.
#include <bits/stdc++.h>
#define _for(i,a,b) for(int i=(a),_b_=(b),_d_=(a<b?1:-1);i!=_b_;i+=_d_)
#define FOR(i,a,b) for(int i = a; i <= b; i++)
#define _it(i,v) for (typeof((v).begin()) i = (v).begin(); i != (v).end(); ++i)
#define _all(v) v.begin(), v.end()
@ititorit
ititorit / AE1B.cpp
Created September 24, 2016 10:26
AE1B SPOJ
// contest: http://www.spoj.com/problems/AE1B/
// author: Nguyễn Minh Tuấn
// language: C/C++
#include <bits/stdc++.h>
#define _for(i,a,b) for(int i=(a),_b_=(b),_d_=(a<b?1:-1);i!=_b_;i+=_d_)
#define FOR(i,a,b) for(int i = a; i <= b; i++)
#define _it(i,v) for (typeof((v).begin()) i = (v).begin(); i != (v).end(); ++i)
#define _all(v) v.begin(), v.end()
@ititorit
ititorit / LASTDIG.cpp
Created September 26, 2016 13:43
SPOJ LASTDIG
#include <bits/stdc++.h>
using namespace std;
int main(){
long long int t,a,b,rm,lst,ans;
int ar[] = {0,0,4,4,2,1,1,4,4,2};
cin >> t;
while(t--){
cin >> a >> b;
lst=a%10;
@ititorit
ititorit / TOANDFRO.cpp
Created September 26, 2016 17:17
TOANDFRO SPOJ
#include <bits/stdc++.h>
#define _for(i,a,b) for(int i=(a),_b_=(b),_d_=(a<b?1:-1);i!=_b_;i+=_d_)
#define FOR(i,a,b) for(int i = a; i <= b; i++)
#define FORD(i,a,b) for(int i = a; i >= b; i--)
#define _it(i,v) for (typeof((v).begin()) i = (v).begin(); i != (v).end(); ++i)
#define _all(v) v.begin(), v.end()
#define DEBUG(x) { cout << #x << " = " << x << endl; }
#define sqr(x) ((x)*(x))
@ititorit
ititorit / SAMER08F.cpp
Created September 27, 2016 10:51
SAMER08F SPOJ
#include <bits/stdc++.h>
#define _for(i,a,b) for(int i=(a),_b_=(b),_d_=(a<b?1:-1);i!=_b_;i+=_d_)
#define FOR(i,a,b) for(int i = a; i <= b; i++)
#define _it(i,v) for (typeof((v).begin()) i = (v).begin(); i != (v).end(); ++i)
#define _all(v) v.begin(), v.end()
#define DEBUG(x) { cout << #x << " = " << x << endl; }
#define sqr(x) ((x)*(x))
@ititorit
ititorit / HUBULLU.cpp
Created September 27, 2016 13:43
HUBULLU SPOJ
#include <bits/stdc++.h>
#define _for(i,a,b) for(int i=(a),_b_=(b),_d_=(a<b?1:-1);i!=_b_;i+=_d_)
#define FOR(i,a,b) for(int i = a; i <= b; i++)
#define _it(i,v) for (typeof((v).begin()) i = (v).begin(); i != (v).end(); ++i)
#define _all(v) v.begin(), v.end()
#define DEBUG(x) { cout << #x << " = " << x << endl; }
#define sqr(x) ((x)*(x))