I am wondering if I could always replace all long long
type into int64_t
type without breaking the program ? Will it somehow affects the program or remains the same ?
And how about the relationship between int
and int32_t
types
# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 150 |
I am wondering if I could always replace all long long
type into int64_t
type without breaking the program ? Will it somehow affects the program or remains the same ?
And how about the relationship between int
and int32_t
types
Recently while I am solving a problem, I realised that increase iterator after erasing the last element of the map (the map is empty) then it would run infinitively
So I stop the loop by adding a small line to check whether it is empty or not
/// map-looping using either iterator or reverse iterator
{
/// some code upper that erase the element but possible to make the map empty
if (map.empty()) break;
}
Is there an alternative way (some other implementations) to prevent from iterator increament when the map is empty (and reverse_iterator
too if possible)
Given two number n and q where 1 ≤ n, q ≤ 10.000
There are n nodes, each node have a green string connect to another. Each 2 node only have 1 string connect between them. There are n * (n — 1) * (n — 2) / 6 total string
You have to answer q queries, each query give 2 number u and v. You paint the string connect (u, v) by color red if they are green, and green if they are red (red <-> green). Then you have to count the number of triangle ABC (1 ≤ A, B, C ≤ n) where (A, B), (B, C), (C, A) have same color (all are red or green).
Time limit for the problem is 1s
Memory limit for the problem is 256Mb
Here are examples
Input:
4 3
1 2
2 3
3 1
Output:
2
1
1
Comment:
(1, 3, 4), (2, 3, 4)
(1, 3, 4)
(1, 2, 3)
Input:
3 5
1 2
2 3
3 1
1 2
1 2
Output:
0
0
1
0
1
Comment:
There are no valid triangle (2, 3), (3, 1) are green while (1, 2) is red
There are no valid triangle (3, 1) is green while (1, 2), (2, 3) are red
(1, 2, 3)
There are no valid triangle (2, 3), (3, 1) are green while (1, 2) is red
(1, 2, 3)
Input:
2 5
1 2
1 2
1 2
1 2
1 2
Output:
0
0
0
0
0
Comment:
There are only two nodes
Notice that the number of valid triangle can be bigger than 10 ^ 9
I think the problem can be solved using map
#include <iostream>
#include <vector>
#include <set>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<vb> vmb;
typedef vector<vi> vmi;
typedef set<int> si;
typedef set<pi> spi;
typedef vector<si> vsi;
int main()
{
int n, q;
cin >> n >> q;
vsi f(n + 1);
ll pre = 1LL * n * (n - 1) * (n - 2) / 6;
while (q--)
{
int u, v;
cin >> u >> v;
ll cnt = pre;
for (int w = 1; w <= n; ++w)
{
if (w == u || w == v) continue;
int t = f[u].count(v) + f[v].count(w) + f[w].count(u);
cnt -= (t == 0 || t == 3);
}
if (f[u].count(v)) f[u].erase(v); else f[u].insert(v);
if (f[v].count(u)) f[v].erase(u); else f[v].insert(u);
for (int w = 1; w <= n; ++w)
{
if (w == u || w == v) continue;
int t = f[u].count(v) + f[v].count(w) + f[w].count(u);
cnt += (t == 0 || t == 3);
}
pre = cnt;
std::cout << cnt << endl;
}
return 0;
}
#include <iostream>
#include <vector>
#include <map>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(u) (u).begin(), (u).end()
#define FastIO ios::sync_with_stdio(NULL),cin.tie(NULL),cout.tie(NULL);
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<vb> vmb;
typedef vector<vi> vmi;
int readInt() { int u; return cin >> u, u; }
ll readLong() { ll u; return cin >> u, u; }
int main()
{
FastIO;
int n = readInt();
ll total = 1LL * n * (n - 1) * (n - 2) / 6;
vi G(n, n - 1);
vi R(n, 0);
ll res = 0;
map<pl, bool> M;
for (int q = readInt(); q--;)
{
ll u = readLong() - 1;
ll v = readLong() - 1;
if (u > v) swap(u, v);
int delta = (M[{u, v}] ^= 1) ? +1 : -1;
res -= (R[u] * G[u] + R[v] * G[v]);
R[u] += delta; R[v] += delta;
G[u] -= delta; G[v] -= delta;
res += (R[u] * G[u] + R[v] * G[v]);
cout << (total - res / 2) << endl;
}
return 0;
}
In this problem. How can I solve it using dsu ?
I see the problem has dsu
-tag, but the editorial but doesnt show dsu approach there :(
#include <iostream>
#include <vector>
using namespace std;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vb> vmb;
typedef vector<vi> vmi;
int main()
{
int n, q;
cin >> n >> q;
vmb f(3, vb(n + 2, false));
int delta = 0;
while (q--)
{
int r, c;
cin >> r >> c;
f[r][c].flip();
if (r == 1)
delta += (f[1][c] ? +1 : -1) * (f[2][c - 1] || f[2][c] || f[2][c + 1]);
else
{
delta += (f[2][c] ? +1 : -1) * (f[1][c] && !f[2][c - 1] && !f[2][c + 1]);
delta += (f[2][c] ? +1 : -1) * (f[1][c - 1] && !f[2][c - 1] && !f[2][max(c - 2, 0)]);
delta += (f[2][c] ? +1 : -1) * (f[1][c + 1] && !f[2][c + 1] && !f[2][min(c + 2, n + 1)]);
}
cout << (delta == 0 ? "Yes\n" : "No\n");
}
return 0;
}
Are there any effeciency algorithms to find shortest path using disjoin-set data structure ?
I know I am a low-ranker contestant. But during the contest, it took me more than 2 minutes just to do something. And every 30 minutes I been logged out and it take me again 3 ~ 5 minutes to log-in. It is very annoy :( Please help me, why the codeforces was so slow. This is the second time I write this blog (The first was ignore by auto-log-out)
Nice logo Codeforces UwU Love it <3
----------
Time to write first 10.000.000 non-negative numbers
(base on Codeforces Custom Test // GNU G++ 17 7.3.0 // GNU G++ 14 6.4.0 // GNU G++ 11 5.1.0)
#include <iostream>
using namespace std;
inline void writeInt(int x)
{
if (x < 0) putchar('-'), x = -x;
int p = 1;
for (int t = x / 10; t > 0; t /= 10)
p *= 10;
for (; p > 0; x %= p, p /= 10)
putchar(x / p + '0');
}
int main()
{
int q = 1e7;
while (q--) writeInt(q);
return 0;
}
#include <iostream>
using namespace std;
inline void writeRec(int n) {
if (n > 9) writeRec(n / 10);
putchar(char(n % 10 + '0'));
}
inline void writeInt(int x)
{
if (x < 0) putchar('-'), x = -x;
writeRec(x);
}
int main()
{
int q = 1e7;
while (q--) writeInt(q);
return 0;
}
#include <iostream>
using namespace std;
#define pc putchar
inline void writeInt(int n)
{
if (n < 0) pc('-'), n = -n;
if (!n) return (void)pc('0');
int t = n, cnt = 0, rev = 0;
while (!(t%10)) { cnt++; t /= 10;}
do {rev=rev*10 + n%10;} while(n /= 10);
do {pc(rev % 10 + 48);} while(rev /= 10);
while (cnt--) pc('0');
}
int main()
{
int q = 1e7;
while (q--) writeInt(q);
return 0;
}
#include <iostream>
using namespace std;
char os[20];
inline void writeInt(int n)
{
if (n < 0) putchar('-'), n = -n;
int i=0;
do os[i++] = n%10; while(n/=10);
while (i--) putchar(os[i] + 48);
}
int main()
{
int q = 1e7;
while (q--) writeInt(q);
return 0;
}
#include <cstdio>
using namespace std;
int main()
{
int q = 1e7;
while (q--) printf("%d", q);
return 0;
}
#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(NULL),cin.tie(NULL),cout.tie(NULL);
int q = 1e7;
while (q--) cout << q;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(true),cin.tie(NULL),cout.tie(NULL);
int q = 1e7;
while (q--) cout << q;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int q = 1e7;
while (q--) cout << q;
return 0;
}
#include <iostream>
using namespace std;
inline void writeInt(int x)
{
if (x < 0) _putchar_nolock('-'), x = -x;
int p = 1;
for (int t = x / 10; t > 0; t /= 10)
p *= 10;
for (; p > 0; x %= p, p /= 10)
_putchar_nolock(x / p + '0');
}
int main()
{
int q = 1e7;
while (q--) writeInt(q);
return 0;
}
#include <iostream>
using namespace std;
#define pc _putchar_nolock
inline void writeInt(int n)
{
if (n < 0) pc('-'), n = -n;
if (!n) return (void)pc('0');
int t = n, cnt = 0, rev = 0;
while (!(t%10)) { cnt++; t /= 10;}
do {rev=rev*10 + n%10;} while(n /= 10);
do {pc(rev % 10 + 48);} while(rev /= 10);
while (cnt--) pc('0');
}
int main()
{
int q = 1e7;
while (q--) writeInt(q);
return 0;
}
#include <iostream>
using namespace std;
inline void writeRec(int n) {
if (n > 9) writeRec(n / 10);
_putchar_nolock(char(n % 10 + '0'));
}
inline void writeInt(int x)
{
if (x < 0) _putchar_nolock('-'), x = -x;
writeRec(x);
}
int main()
{
int q = 1e7;
while (q--) writeInt(q);
return 0;
}
#include <iostream>
using namespace std;
char os[20];
inline void writeInt(int n)
{
if (n < 0) _putchar_nolock('-'), n = -n;
int i=0;
do os[i++] = n%10; while(n/=10);
while (i--) _putchar_nolock(os[i] + 48);
}
int main()
{
int q = 1e7;
while (q--) writeInt(q);
return 0;
}
#include <iostream>
using namespace std;
static const int buf_len = (1 << 14);
static const int buf_max = (1 << 04);
static char buf_out[buf_len];
static char buf_num[buf_max];
static int buf_pos = 0;
inline void writeChar(int x) {
if (buf_pos == buf_len) fwrite(buf_out, 1, buf_len, stdout), buf_pos = 0;
buf_out[buf_pos++] = x;
}
inline void writeInt(int x, char end = 0) {
if (x < 0) writeChar('-'), x = -x;
int n = 0;
do buf_num[n++] = x % 10 + '0'; while(x /= 10);
while (n--) writeChar(buf_num[n]);
if (end) writeChar(end);
}
struct Flusher{~Flusher(){if(buf_pos)fwrite(buf_out, 1, buf_pos, stdout),buf_pos=0;}}flusher;
int main()
{
int q = 1e7;
while (q--) writeInt(q); Flusher();
return 0;
}
#include <iostream>
using namespace std;
inline void writeInt(int x)
{
if (x < 0) putchar('-'), x = -x;
int p = 1;
for (int t = x / 10; t > 0; t /= 10)
p *= 10;
for (; p > 0; x %= p, p /= 10)
putchar(x / p + '0');
}
int main()
{
int q = 1e7;
while (q--) writeInt(q);
return 0;
}
#include <iostream>
using namespace std;
#define pc putchar
inline void writeInt(int n)
{
if (n < 0) pc('-'), n = -n;
if (!n) return (void)pc('0');
int t = n, cnt = 0, rev = 0;
while (!(t%10)) { cnt++; t /= 10;}
do {rev=rev*10 + n%10;} while(n /= 10);
do {pc(rev % 10 + 48);} while(rev /= 10);
while (cnt--) pc('0');
}
int main()
{
int q = 1e7;
while (q--) writeInt(q);
return 0;
}
#include <iostream>
using namespace std;
inline void writeRec(int n) {
if (n > 9) writeRec(n / 10);
putchar(char(n % 10 + '0'));
}
inline void writeInt(int x)
{
if (x < 0) putchar('-'), x = -x;
writeRec(x);
}
int main()
{
int q = 1e7;
while (q--) writeInt(q);
return 0;
}
#include <iostream>
using namespace std;
char os[20];
inline void writeInt(int n)
{
if (n < 0) putchar('-'), n = -n;
int i=0;
do os[i++] = n%10; while(n/=10);
while (i--) putchar(os[i] + 48);
}
int main()
{
int q = 1e7;
while (q--) writeInt(q);
return 0;
}
#include <cstdio>
using namespace std;
int main()
{
int q = 1e7;
while (q--) printf("%d", q);
return 0;
}
#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(NULL),cin.tie(NULL),cout.tie(NULL);
int q = 1e7;
while (q--) cout << q;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(true),cin.tie(NULL),cout.tie(NULL);
int q = 1e7;
while (q--) cout << q;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int q = 1e7;
while (q--) cout << q;
return 0;
}
#include <iostream>
using namespace std;
inline void writeInt(int x)
{
if (x < 0) _putchar_nolock('-'), x = -x;
int p = 1;
for (int t = x / 10; t > 0; t /= 10)
p *= 10;
for (; p > 0; x %= p, p /= 10)
_putchar_nolock(x / p + '0');
}
int main()
{
int q = 1e7;
while (q--) writeInt(q);
return 0;
}
#include <iostream>
using namespace std;
#define pc _putchar_nolock
inline void writeInt(int n)
{
if (n < 0) pc('-'), n = -n;
if (!n) return (void)pc('0');
int t = n, cnt = 0, rev = 0;
while (!(t%10)) { cnt++; t /= 10;}
do {rev=rev*10 + n%10;} while(n /= 10);
do {pc(rev % 10 + 48);} while(rev /= 10);
while (cnt--) pc('0');
}
int main()
{
int q = 1e7;
while (q--) writeInt(q);
return 0;
}
#include <iostream>
using namespace std;
inline void writeRec(int n) {
if (n > 9) writeRec(n / 10);
_putchar_nolock(char(n % 10 + '0'));
}
inline void writeInt(int x)
{
if (x < 0) _putchar_nolock('-'), x = -x;
writeRec(x);
}
int main()
{
int q = 1e7;
while (q--) writeInt(q);
return 0;
}
#include <iostream>
using namespace std;
char os[20];
inline void writeInt(int n)
{
if (n < 0) _putchar_nolock('-'), n = -n;
int i=0;
do os[i++] = n%10; while(n/=10);
while (i--) _putchar_nolock(os[i] + 48);
}
int main()
{
int q = 1e7;
while (q--) writeInt(q);
return 0;
}
#include <iostream>
using namespace std;
static const int buf_len = (1 << 14);
static const int buf_max = (1 << 04);
static char buf_out[buf_len];
static char buf_num[buf_max];
static int buf_pos = 0;
inline void writeChar(int x) {
if (buf_pos == buf_len) fwrite(buf_out, 1, buf_len, stdout), buf_pos = 0;
buf_out[buf_pos++] = x;
}
inline void writeInt(int x, char end = 0) {
if (x < 0) writeChar('-'), x = -x;
int n = 0;
do buf_num[n++] = x % 10 + '0'; while(x /= 10);
while (n--) writeChar(buf_num[n]);
if (end) writeChar(end);
}
struct Flusher{~Flusher(){if(buf_pos)fwrite(buf_out, 1, buf_pos, stdout),buf_pos=0;}}flusher;
int main()
{
int q = 1e7;
while (q--) writeInt(q); Flusher();
return 0;
}
#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(NULL),cin.tie(NULL),cout.tie(NULL);
int q = 1e7;
while (q--) cout << q;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(true),cin.tie(NULL),cout.tie(NULL);
int q = 1e7;
while (q--) cout << q;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int q = 1e7;
while (q--) cout << q;
return 0;
}
#include <cstdio>
using namespace std;
int main()
{
int q = 1e7;
while (q--) printf("%d", q);
return 0;
}
#include <iostream>
using namespace std;
inline void writeInt(int x)
{
if (x < 0) putchar('-'), x = -x;
int p = 1;
for (int t = x / 10; t > 0; t /= 10)
p *= 10;
for (; p > 0; x %= p, p /= 10)
putchar(x / p + '0');
}
int main()
{
int q = 1e7;
while (q--) writeInt(q);
return 0;
}
#include <iostream>
using namespace std;
#define pc putchar
inline void writeInt(int n)
{
if (n < 0) pc('-'), n = -n;
if (!n) return (void)pc('0');
int t = n, cnt = 0, rev = 0;
while (!(t%10)) { cnt++; t /= 10;}
do {rev=rev*10 + n%10;} while(n /= 10);
do {pc(rev % 10 + 48);} while(rev /= 10);
while (cnt--) pc('0');
}
int main()
{
int q = 1e7;
while (q--) writeInt(q);
return 0;
}
#include <iostream>
using namespace std;
char os[20];
inline void writeInt(int n)
{
if (n < 0) putchar('-'), n = -n;
int i=0;
do os[i++] = n%10; while(n/=10);
while (i--) putchar(os[i] + 48);
}
int main()
{
int q = 1e7;
while (q--) writeInt(q);
return 0;
}
#include <iostream>
using namespace std;
inline void writeRec(int n) {
if (n > 9) writeRec(n / 10);
putchar(char(n % 10 + '0'));
}
inline void writeInt(int x)
{
if (x < 0) putchar('-'), x = -x;
writeRec(x);
}
int main()
{
int q = 1e7;
while (q--) writeInt(q);
return 0;
}
#include <iostream>
using namespace std;
static const int buf_len = (1 << 14);
static const int buf_max = (1 << 04);
static char buf_out[buf_len];
static char buf_num[buf_max];
static int buf_pos = 0;
inline void writeChar(int x) {
if (buf_pos == buf_len) fwrite(buf_out, 1, buf_len, stdout), buf_pos = 0;
buf_out[buf_pos++] = x;
}
inline void writeInt(int x, char end = 0) {
if (x < 0) writeChar('-'), x = -x;
int n = 0;
do buf_num[n++] = x % 10 + '0'; while(x /= 10);
while (n--) writeChar(buf_num[n]);
if (end) writeChar(end);
}
struct Flusher{~Flusher(){if(buf_pos)fwrite(buf_out, 1, buf_pos, stdout),buf_pos=0;}}flusher;
int main()
{
int q = 1e7;
while (q--) writeInt(q); Flusher();
return 0;
}
#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(true),cin.tie(NULL),cout.tie(NULL);
int q = 1e7;
while (q--) cout << q;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(NULL),cin.tie(NULL),cout.tie(NULL);
int q = 1e7;
while (q--) cout << q;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int q = 1e7;
while (q--) cout << q;
return 0;
}
#include <iostream>
using namespace std;
#define pc putchar
inline void writeInt(int n)
{
if (n < 0) pc('-'), n = -n;
if (!n) return (void)pc('0');
int t = n, cnt = 0, rev = 0;
while (!(t%10)) { cnt++; t /= 10;}
do {rev=rev*10 + n%10;} while(n /= 10);
do {pc(rev % 10 + 48);} while(rev /= 10);
while (cnt--) pc('0');
}
int main()
{
int q = 1e7;
while (q--) writeInt(q);
return 0;
}
#include <iostream>
using namespace std;
inline void writeInt(int x)
{
if (x < 0) putchar('-'), x = -x;
int p = 1;
for (int t = x / 10; t > 0; t /= 10)
p *= 10;
for (; p > 0; x %= p, p /= 10)
putchar(x / p + '0');
}
int main()
{
int q = 1e7;
while (q--) writeInt(q);
return 0;
}
#include <iostream>
using namespace std;
char os[20];
inline void writeInt(int n)
{
if (n < 0) putchar('-'), n = -n;
int i=0;
do os[i++] = n%10; while(n/=10);
while (i--) putchar(os[i] + 48);
}
int main()
{
int q = 1e7;
while (q--) writeInt(q);
return 0;
}
#include <iostream>
using namespace std;
inline void writeRec(int n) {
if (n > 9) writeRec(n / 10);
putchar(char(n % 10 + '0'));
}
inline void writeInt(int x)
{
if (x < 0) putchar('-'), x = -x;
writeRec(x);
}
int main()
{
int q = 1e7;
while (q--) writeInt(q);
return 0;
}
#include <cstdio>
using namespace std;
int main()
{
int q = 1e7;
while (q--) printf("%d", q);
return 0;
}
#include <iostream>
using namespace std;
static const int buf_len = (1 << 14);
static const int buf_max = (1 << 04);
static char buf_out[buf_len];
static char buf_num[buf_max];
static int buf_pos = 0;
inline void writeChar(int x) {
if (buf_pos == buf_len) fwrite(buf_out, 1, buf_len, stdout), buf_pos = 0;
buf_out[buf_pos++] = x;
}
inline void writeInt(int x, char end = 0) {
if (x < 0) writeChar('-'), x = -x;
int n = 0;
do buf_num[n++] = x % 10 + '0'; while(x /= 10);
while (n--) writeChar(buf_num[n]);
if (end) writeChar(end);
}
struct Flusher{~Flusher(){if(buf_pos)fwrite(buf_out, 1, buf_pos, stdout),buf_pos=0;}}flusher;
int main()
{
int q = 1e7;
while (q--) writeInt(q); Flusher();
return 0;
}
#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(NULL),cin.tie(NULL),cout.tie(NULL);
int q = 1e7;
while (q--) cout << q;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(true),cin.tie(NULL),cout.tie(NULL);
int q = 1e7;
while (q--) cout << q;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int q = 1e7;
while (q--) cout << q;
return 0;
}
#include <iostream>
using namespace std;
inline void writeInt(int x)
{
if (x < 0) putchar('-'), x = -x;
int p = 1;
for (int t = x / 10; t > 0; t /= 10)
p *= 10;
for (; p > 0; x %= p, p /= 10)
putchar(x / p + '0');
}
int main()
{
int q = 1e7;
while (q--) writeInt(q);
return 0;
}
#include <iostream>
using namespace std;
#define pc putchar
inline void writeInt(int n)
{
if (n < 0) pc('-'), n = -n;
if (!n) return (void)pc('0');
int t = n, cnt = 0, rev = 0;
while (!(t%10)) { cnt++; t /= 10;}
do {rev=rev*10 + n%10;} while(n /= 10);
do {pc(rev % 10 + 48);} while(rev /= 10);
while (cnt--) pc('0');
}
int main()
{
int q = 1e7;
while (q--) writeInt(q);
return 0;
}
#include <iostream>
using namespace std;
char os[20];
inline void writeInt(int n)
{
if (n < 0) putchar('-'), n = -n;
int i=0;
do os[i++] = n%10; while(n/=10);
while (i--) putchar(os[i] + 48);
}
int main()
{
int q = 1e7;
while (q--) writeInt(q);
return 0;
}
#include <iostream>
using namespace std;
inline void writeRec(int n) {
if (n > 9) writeRec(n / 10);
putchar(char(n % 10 + '0'));
}
inline void writeInt(int x)
{
if (x < 0) putchar('-'), x = -x;
writeRec(x);
}
int main()
{
int q = 1e7;
while (q--) writeInt(q);
return 0;
}
#include <cstdio>
using namespace std;
int main()
{
int q = 1e7;
while (q--) printf("%d", q);
return 0;
}
#include <iostream>
using namespace std;
static const int buf_len = (1 << 14);
static const int buf_max = (1 << 04);
static char buf_out[buf_len];
static char buf_num[buf_max];
static int buf_pos = 0;
inline void writeChar(int x) {
if (buf_pos == buf_len) fwrite(buf_out, 1, buf_len, stdout), buf_pos = 0;
buf_out[buf_pos++] = x;
}
inline void writeInt(int x, char end = 0) {
if (x < 0) writeChar('-'), x = -x;
int n = 0;
do buf_num[n++] = x % 10 + '0'; while(x /= 10);
while (n--) writeChar(buf_num[n]);
if (end) writeChar(end);
}
struct Flusher{~Flusher(){if(buf_pos)fwrite(buf_out, 1, buf_pos, stdout),buf_pos=0;}}flusher;
int main()
{
int q = 1e7;
while (q--) writeInt(q); Flusher();
return 0;
}
Time to write 1.000 times first 10000 numbers
(base on Codeforces Custom Test // GNU G++ 17 7.3.0 // GNU G++ 14 6.4.0 // GNU G++ 11 5.1.0)
#include <iostream>
using namespace std;
#define pc putchar
inline void writeInt(int n)
{
if (n < 0) pc('-'), n = -n;
if (!n) return (void)pc('0');
int t = n, cnt = 0, rev = 0;
while (!(t%10)) { cnt++; t /= 10;}
do {rev=rev*10 + n%10;} while(n /= 10);
do {pc(rev % 10 + 48);} while(rev /= 10);
while (cnt--) pc('0');
}
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
writeInt(i);
return 0;
}
#include <iostream>
using namespace std;
inline void writeInt(int x)
{
if (x < 0) putchar('-'), x = -x;
int p = 1;
for (int t = x / 10; t > 0; t /= 10)
p *= 10;
for (; p > 0; x %= p, p /= 10)
putchar(x / p + '0');
}
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
writeInt(i);
return 0;
}
#include <iostream>
using namespace std;
char os[20];
inline void writeInt(int n)
{
if (n < 0) putchar('-'), n = -n;
int i=0;
do os[i++] = n%10; while(n/=10);
while (i--) putchar(os[i] + 48);
}
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
writeInt(i);
return 0;
}
#include <iostream>
using namespace std;
inline void writeRec(int n) {
if (n > 9) writeRec(n / 10);
putchar(char(n % 10 + '0'));
}
inline void writeInt(int x)
{
if (x < 0) putchar('-'), x = -x;
writeRec(x);
}
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
writeInt(i);
return 0;
}
#include <cstdio>
using namespace std;
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
printf("%d", i);
return 0;
}
#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(true),cin.tie(NULL),cout.tie(NULL);
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
cout << i;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
cout << i;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(NULL),cin.tie(NULL),cout.tie(NULL);
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
cout << i;
return 0;
}
#include <iostream>
using namespace std;
inline void writeInt(int x)
{
if (x < 0) _putchar_nolock('-'), x = -x;
int p = 1;
for (int t = x / 10; t > 0; t /= 10)
p *= 10;
for (; p > 0; x %= p, p /= 10)
_putchar_nolock(x / p + '0');
}
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
writeInt(i);
return 0;
}
#include <iostream>
using namespace std;
#define pc _putchar_nolock
inline void writeInt(int n)
{
if (n < 0) pc('-'), n = -n;
if (!n) return (void)pc('0');
int t = n, cnt = 0, rev = 0;
while (!(t%10)) { cnt++; t /= 10;}
do {rev=rev*10 + n%10;} while(n /= 10);
do {pc(rev % 10 + 48);} while(rev /= 10);
while (cnt--) pc('0');
}
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
writeInt(i);
return 0;
}
#include <iostream>
using namespace std;
inline void writeRec(int n) {
if (n > 9) writeRec(n / 10);
_putchar_nolock(char(n % 10 + '0'));
}
inline void writeInt(int x)
{
if (x < 0) _putchar_nolock('-'), x = -x;
writeRec(x);
}
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
writeInt(i);
return 0;
}
#include <iostream>
using namespace std;
char os[20];
inline void writeInt(int n)
{
if (n < 0) _putchar_nolock('-'), n = -n;
int i=0;
do os[i++] = n%10; while(n/=10);
while (i--) _putchar_nolock(os[i] + 48);
}
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
writeInt(i);
return 0;
}
#include <iostream>
using namespace std;
static const int buf_len = (1 << 14);
static const int buf_max = (1 << 04);
static char buf_out[buf_len];
static char buf_num[buf_max];
static int buf_pos = 0;
inline void writeChar(int x) {
if (buf_pos == buf_len) fwrite(buf_out, 1, buf_len, stdout), buf_pos = 0;
buf_out[buf_pos++] = x;
}
inline void writeInt(int x, char end = 0) {
if (x < 0) writeChar('-'), x = -x;
int n = 0;
do buf_num[n++] = x % 10 + '0'; while(x /= 10);
while (n--) writeChar(buf_num[n]);
if (end) writeChar(end);
}
struct Flusher{~Flusher(){if(buf_pos)fwrite(buf_out, 1, buf_pos, stdout),buf_pos=0;}}flusher;
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
writeInt(i);
Flusher();
return 0;
}
#include <iostream>
using namespace std;
#define pc putchar
inline void writeInt(int n)
{
if (n < 0) pc('-'), n = -n;
if (!n) return (void)pc('0');
int t = n, cnt = 0, rev = 0;
while (!(t%10)) { cnt++; t /= 10;}
do {rev=rev*10 + n%10;} while(n /= 10);
do {pc(rev % 10 + 48);} while(rev /= 10);
while (cnt--) pc('0');
}
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
writeInt(i);
return 0;
}
#include <iostream>
using namespace std;
inline void writeInt(int x)
{
if (x < 0) putchar('-'), x = -x;
int p = 1;
for (int t = x / 10; t > 0; t /= 10)
p *= 10;
for (; p > 0; x %= p, p /= 10)
putchar(x / p + '0');
}
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
writeInt(i);
return 0;
}
#include <iostream>
using namespace std;
char os[20];
inline void writeInt(int n)
{
if (n < 0) putchar('-'), n = -n;
int i=0;
do os[i++] = n%10; while(n/=10);
while (i--) putchar(os[i] + 48);
}
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
writeInt(i);
return 0;
}
#include <iostream>
using namespace std;
inline void writeRec(int n) {
if (n > 9) writeRec(n / 10);
putchar(char(n % 10 + '0'));
}
inline void writeInt(int x)
{
if (x < 0) putchar('-'), x = -x;
writeRec(x);
}
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
writeInt(i);
return 0;
}
#include <cstdio>
using namespace std;
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
printf("%d", i);
return 0;
}
#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(NULL),cin.tie(NULL),cout.tie(NULL);
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
cout << i;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(true),cin.tie(NULL),cout.tie(NULL);
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
cout << i;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
cout << i;
return 0;
}
#include <iostream>
using namespace std;
inline void writeInt(int x)
{
if (x < 0) _putchar_nolock('-'), x = -x;
int p = 1;
for (int t = x / 10; t > 0; t /= 10)
p *= 10;
for (; p > 0; x %= p, p /= 10)
_putchar_nolock(x / p + '0');
}
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
writeInt(i);
return 0;
}
#include <iostream>
using namespace std;
#define pc _putchar_nolock
inline void writeInt(int n)
{
if (n < 0) pc('-'), n = -n;
if (!n) return (void)pc('0');
int t = n, cnt = 0, rev = 0;
while (!(t%10)) { cnt++; t /= 10;}
do {rev=rev*10 + n%10;} while(n /= 10);
do {pc(rev % 10 + 48);} while(rev /= 10);
while (cnt--) pc('0');
}
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
writeInt(i);
return 0;
}
#include <iostream>
using namespace std;
char os[20];
inline void writeInt(int n)
{
if (n < 0) _putchar_nolock('-'), n = -n;
int i=0;
do os[i++] = n%10; while(n/=10);
while (i--) _putchar_nolock(os[i] + 48);
}
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
writeInt(i);
return 0;
}
#include <iostream>
using namespace std;
inline void writeRec(int n) {
if (n > 9) writeRec(n / 10);
_putchar_nolock(char(n % 10 + '0'));
}
inline void writeInt(int x)
{
if (x < 0) _putchar_nolock('-'), x = -x;
writeRec(x);
}
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
writeInt(i);
return 0;
}
#include <iostream>
using namespace std;
static const int buf_len = (1 << 14);
static const int buf_max = (1 << 04);
static char buf_out[buf_len];
static char buf_num[buf_max];
static int buf_pos = 0;
inline void writeChar(int x) {
if (buf_pos == buf_len) fwrite(buf_out, 1, buf_len, stdout), buf_pos = 0;
buf_out[buf_pos++] = x;
}
inline void writeInt(int x, char end = 0) {
if (x < 0) writeChar('-'), x = -x;
int n = 0;
do buf_num[n++] = x % 10 + '0'; while(x /= 10);
while (n--) writeChar(buf_num[n]);
if (end) writeChar(end);
}
struct Flusher{~Flusher(){if(buf_pos)fwrite(buf_out, 1, buf_pos, stdout),buf_pos=0;}}flusher;
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
writeInt(i);
Flusher();
return 0;
}
#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(true),cin.tie(NULL),cout.tie(NULL);
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
cout << i;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
cout << i;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(NULL),cin.tie(NULL),cout.tie(NULL);
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
cout << i;
return 0;
}
#include <cstdio>
using namespace std;
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
printf("%d", i);
return 0;
}
#include <iostream>
using namespace std;
inline void writeInt(int x)
{
if (x < 0) putchar('-'), x = -x;
int p = 1;
for (int t = x / 10; t > 0; t /= 10)
p *= 10;
for (; p > 0; x %= p, p /= 10)
putchar(x / p + '0');
}
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
writeInt(i);
return 0;
}
#include <iostream>
using namespace std;
#define pc putchar
inline void writeInt(int n)
{
if (n < 0) pc('-'), n = -n;
if (!n) return (void)pc('0');
int t = n, cnt = 0, rev = 0;
while (!(t%10)) { cnt++; t /= 10;}
do {rev=rev*10 + n%10;} while(n /= 10);
do {pc(rev % 10 + 48);} while(rev /= 10);
while (cnt--) pc('0');
}
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
writeInt(i);
return 0;
}
#include <iostream>
using namespace std;
static const int buf_len = (1 << 14);
static const int buf_max = (1 << 04);
static char buf_out[buf_len];
static char buf_num[buf_max];
static int buf_pos = 0;
inline void writeChar(int x) {
if (buf_pos == buf_len) fwrite(buf_out, 1, buf_len, stdout), buf_pos = 0;
buf_out[buf_pos++] = x;
}
inline void writeInt(int x, char end = 0) {
if (x < 0) writeChar('-'), x = -x;
int n = 0;
do buf_num[n++] = x % 10 + '0'; while(x /= 10);
while (n--) writeChar(buf_num[n]);
if (end) writeChar(end);
}
struct Flusher{~Flusher(){if(buf_pos)fwrite(buf_out, 1, buf_pos, stdout),buf_pos=0;}}flusher;
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
writeInt(i);
Flusher();
return 0;
}
#include <iostream>
using namespace std;
char os[20];
inline void writeInt(int n)
{
if (n < 0) putchar('-'), n = -n;
int i=0;
do os[i++] = n%10; while(n/=10);
while (i--) putchar(os[i] + 48);
}
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
writeInt(i);
return 0;
}
#include <iostream>
using namespace std;
inline void writeRec(int n) {
if (n > 9) writeRec(n / 10);
putchar(char(n % 10 + '0'));
}
inline void writeInt(int x)
{
if (x < 0) putchar('-'), x = -x;
writeRec(x);
}
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
writeInt(i);
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
cout << i;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(true),cin.tie(NULL),cout.tie(NULL);
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
cout << i;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(NULL),cin.tie(NULL),cout.tie(NULL);
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
cout << i;
return 0;
}
#include <cstdio>
using namespace std;
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
printf("%d", i);
return 0;
}
#include <iostream>
using namespace std;
#define pc putchar
inline void writeInt(int n)
{
if (n < 0) pc('-'), n = -n;
if (!n) return (void)pc('0');
int t = n, cnt = 0, rev = 0;
while (!(t%10)) { cnt++; t /= 10;}
do {rev=rev*10 + n%10;} while(n /= 10);
do {pc(rev % 10 + 48);} while(rev /= 10);
while (cnt--) pc('0');
}
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
writeInt(i);
return 0;
}
#include <iostream>
using namespace std;
inline void writeInt(int x)
{
if (x < 0) putchar('-'), x = -x;
int p = 1;
for (int t = x / 10; t > 0; t /= 10)
p *= 10;
for (; p > 0; x %= p, p /= 10)
putchar(x / p + '0');
}
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
writeInt(i);
return 0;
}
#include <iostream>
using namespace std;
inline void writeRec(int n) {
if (n > 9) writeRec(n / 10);
putchar(char(n % 10 + '0'));
}
inline void writeInt(int x)
{
if (x < 0) putchar('-'), x = -x;
writeRec(x);
}
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
writeInt(i);
return 0;
}
#include <iostream>
using namespace std;
char os[20];
inline void writeInt(int n)
{
if (n < 0) putchar('-'), n = -n;
int i=0;
do os[i++] = n%10; while(n/=10);
while (i--) putchar(os[i] + 48);
}
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
writeInt(i);
return 0;
}
#include <iostream>
using namespace std;
static const int buf_len = (1 << 14);
static const int buf_max = (1 << 04);
static char buf_out[buf_len];
static char buf_num[buf_max];
static int buf_pos = 0;
inline void writeChar(int x) {
if (buf_pos == buf_len) fwrite(buf_out, 1, buf_len, stdout), buf_pos = 0;
buf_out[buf_pos++] = x;
}
inline void writeInt(int x, char end = 0) {
if (x < 0) writeChar('-'), x = -x;
int n = 0;
do buf_num[n++] = x % 10 + '0'; while(x /= 10);
while (n--) writeChar(buf_num[n]);
if (end) writeChar(end);
}
struct Flusher{~Flusher(){if(buf_pos)fwrite(buf_out, 1, buf_pos, stdout),buf_pos=0;}}flusher;
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
writeInt(i);
Flusher();
return 0;
}
#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(true),cin.tie(NULL),cout.tie(NULL);
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
cout << i;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(NULL),cin.tie(NULL),cout.tie(NULL);
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
cout << i;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
cout << i;
return 0;
}
#include <cstdio>
using namespace std;
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
printf("%d", i);
return 0;
}
#include <iostream>
using namespace std;
inline void writeInt(int x)
{
if (x < 0) putchar('-'), x = -x;
int p = 1;
for (int t = x / 10; t > 0; t /= 10)
p *= 10;
for (; p > 0; x %= p, p /= 10)
putchar(x / p + '0');
}
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
writeInt(i);
return 0;
}
#include <iostream>
using namespace std;
#define pc putchar
inline void writeInt(int n)
{
if (n < 0) pc('-'), n = -n;
if (!n) return (void)pc('0');
int t = n, cnt = 0, rev = 0;
while (!(t%10)) { cnt++; t /= 10;}
do {rev=rev*10 + n%10;} while(n /= 10);
do {pc(rev % 10 + 48);} while(rev /= 10);
while (cnt--) pc('0');
}
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
writeInt(i);
return 0;
}
#include <iostream>
using namespace std;
char os[20];
inline void writeInt(int n)
{
if (n < 0) putchar('-'), n = -n;
int i=0;
do os[i++] = n%10; while(n/=10);
while (i--) putchar(os[i] + 48);
}
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
writeInt(i);
return 0;
}
#include <iostream>
using namespace std;
inline void writeRec(int n) {
if (n > 9) writeRec(n / 10);
putchar(char(n % 10 + '0'));
}
inline void writeInt(int x)
{
if (x < 0) putchar('-'), x = -x;
writeRec(x);
}
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
writeInt(i);
return 0;
}
#include <iostream>
using namespace std;
static const int buf_len = (1 << 14);
static const int buf_max = (1 << 04);
static char buf_out[buf_len];
static char buf_num[buf_max];
static int buf_pos = 0;
inline void writeChar(int x) {
if (buf_pos == buf_len) fwrite(buf_out, 1, buf_len, stdout), buf_pos = 0;
buf_out[buf_pos++] = x;
}
inline void writeInt(int x, char end = 0) {
if (x < 0) writeChar('-'), x = -x;
int n = 0;
do buf_num[n++] = x % 10 + '0'; while(x /= 10);
while (n--) writeChar(buf_num[n]);
if (end) writeChar(end);
}
struct Flusher{~Flusher(){if(buf_pos)fwrite(buf_out, 1, buf_pos, stdout),buf_pos=0;}}flusher;
int main()
{
int q = 1e3;
while (q--)
for (int i = 0; i <= 1e4; ++i)
writeInt(i);
Flusher();
return 0;
}
Time to write first 10.000.000 non-positive numbers
(base on Codeforces Custom Test // GNU G++ 17 7.3.0 // GNU G++ 14 6.4.0 // GNU G++ 11 5.1.0)
#include <iostream>
using namespace std;
char os[20];
inline void writeInt(int n)
{
if (n < 0) putchar('-'), n = -n;
int i=0;
do os[i++] = n%10; while(n/=10);
while (i--) putchar(os[i] + 48);
}
int main()
{
int q = 1e7;
while (q--) writeInt(-q);
return 0;
}
#include <iostream>
using namespace std;
#define pc putchar
inline void writeInt(int n)
{
if (n < 0) pc('-'), n = -n;
if (!n) return (void)pc('0');
int t = n, cnt = 0, rev = 0;
while (!(t%10)) { cnt++; t /= 10;}
do {rev=rev*10 + n%10;} while(n /= 10);
do {pc(rev % 10 + 48);} while(rev /= 10);
while (cnt--) pc('0');
}
int main()
{
int q = 1e7;
while (q--) writeInt(-q);
return 0;
}
#include <iostream>
using namespace std;
inline void writeRec(int n) {
if (n > 9) writeRec(n / 10);
putchar(char(n % 10 + '0'));
}
inline void writeInt(int x)
{
if (x < 0) putchar('-');
writeRec(abs(x));
}
int main()
{
int q = 1e7;
while (q--) writeInt(-q);
return 0;
}
#include <iostream>
using namespace std;
inline void writeInt(int x)
{
if (x < 0) putchar('-'), x = -x;
int p = 1;
for (int t = x / 10; t > 0; t /= 10)
p *= 10;
for (; p > 0; x %= p, p /= 10) putchar(x / p + '0');
}
int main()
{
int q = 1e7;
while (q--) writeInt(-q);
return 0;
}
#include <cstdio>
using namespace std;
int main()
{
int q = 1e7;
while (q--) printf("%d", -q);
return 0;
}
#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(NULL),cin.tie(NULL),cout.tie(NULL);
int q = 1e7;
while (q--) cout << -q;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(true),cin.tie(NULL),cout.tie(NULL);
int q = 1e7;
while (q--) cout << -q;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int q = 1e7;
while (q--) cout << -q;
return 0;
}
#include <iostream>
using namespace std;
inline void writeInt(int x)
{
if (x < 0) _putchar_nolock('-'), x = -x;
int p = 1;
for (int t = x / 10; t > 0; t /= 10)
p *= 10;
for (; p > 0; x %= p, p /= 10)
_putchar_nolock(x / p + '0');
}
int main()
{
int q = 1e7;
while (q--) writeInt(-q);
return 0;
}
#include <iostream>
using namespace std;
#define pc _putchar_nolock
inline void writeInt(int n)
{
if (n < 0) pc('-'), n = -n;
if (!n) return (void)pc('0');
int t = n, cnt = 0, rev = 0;
while (!(t%10)) { cnt++; t /= 10;}
do {rev=rev*10 + n%10;} while(n /= 10);
do {pc(rev % 10 + 48);} while(rev /= 10);
while (cnt--) pc('0');
}
int main()
{
int q = 1e7;
while (q--) writeInt(-q);
return 0;
}
#include <iostream>
using namespace std;
char os[20];
inline void writeInt(int n)
{
if (n < 0) _putchar_nolock('-'), n = -n;
int i=0;
do os[i++] = n%10; while(n/=10);
while (i--) _putchar_nolock(os[i] + 48);
}
int main()
{
int q = 1e7;
while (q--) writeInt(-q);
return 0;
}
#include <iostream>
using namespace std;
inline void writeRec(int n) {
if (n > 9) writeRec(n / 10);
_putchar_nolock(char(n % 10 + '0'));
}
inline void writeInt(int x)
{
if (x < 0) _putchar_nolock('-'), x = -x;
writeRec(x);
}
int main()
{
int q = 1e7;
while (q--) writeInt(-q);
return 0;
}
#include <iostream>
using namespace std;
static const int buf_len = (1 << 14);
static const int buf_max = (1 << 04);
static char buf_out[buf_len];
static char buf_num[buf_max];
static int buf_pos = 0;
inline void writeChar(int x) {
if (buf_pos == buf_len) fwrite(buf_out, 1, buf_len, stdout), buf_pos = 0;
buf_out[buf_pos++] = x;
}
inline void writeInt(int x, char end = 0) {
if (x < 0) writeChar('-'), x = -x;
int n = 0;
do buf_num[n++] = x % 10 + '0'; while(x /= 10);
while (n--) writeChar(buf_num[n]);
if (end) writeChar(end);
}
struct Flusher{~Flusher(){if(buf_pos)fwrite(buf_out, 1, buf_pos, stdout),buf_pos=0;}}flusher;
int main()
{
int q = 1e7;
while (q--) writeInt(-q); Flusher();
return 0;
}
#include <iostream>
using namespace std;
#define pc putchar
inline void writeInt(int n)
{
if (n < 0) pc('-'), n = -n;
if (!n) return (void)pc('0');
int t = n, cnt = 0, rev = 0;
while (!(t%10)) { cnt++; t /= 10;}
do {rev=rev*10 + n%10;} while(n /= 10);
do {pc(rev % 10 + 48);} while(rev /= 10);
while (cnt--) pc('0');
}
int main()
{
int q = 1e7;
while (q--) writeInt(-q);
return 0;
}
#include <iostream>
using namespace std;
inline void writeRec(int n) {
if (n > 9) writeRec(n / 10);
putchar(char(n % 10 + '0'));
}
inline void writeInt(int x)
{
if (x < 0) putchar('-');
writeRec(abs(x));
}
int main()
{
int q = 1e7;
while (q--) writeInt(-q);
return 0;
}
#include <iostream>
using namespace std;
inline void writeInt(int x)
{
if (x < 0) putchar('-'), x = -x;
int p = 1;
for (int t = x / 10; t > 0; t /= 10)
p *= 10;
for (; p > 0; x %= p, p /= 10) putchar(x / p + '0');
}
int main()
{
int q = 1e7;
while (q--) writeInt(-q);
return 0;
}
#include <iostream>
using namespace std;
char os[20];
inline void writeInt(int n)
{
if (n < 0) putchar('-'), n = -n;
int i=0;
do os[i++] = n%10; while(n/=10);
while (i--) putchar(os[i] + 48);
}
int main()
{
int q = 1e7;
while (q--) writeInt(-q);
return 0;
}
#include <cstdio>
using namespace std;
int main()
{
int q = 1e7;
while (q--) printf("%d", -q);
return 0;
}
#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(NULL),cin.tie(NULL),cout.tie(NULL);
int q = 1e7;
while (q--) cout << -q;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int q = 1e7;
while (q--) cout << -q;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(true),cin.tie(NULL),cout.tie(NULL);
int q = 1e7;
while (q--) cout << -q;
return 0;
}
#include <iostream>
using namespace std;
inline void writeInt(int x)
{
if (x < 0) _putchar_nolock('-'), x = -x;
int p = 1;
for (int t = x / 10; t > 0; t /= 10)
p *= 10;
for (; p > 0; x %= p, p /= 10)
_putchar_nolock(x / p + '0');
}
int main()
{
int q = 1e7;
while (q--) writeInt(-q);
return 0;
}
#include <iostream>
using namespace std;
#define pc _putchar_nolock
inline void writeInt(int n)
{
if (n < 0) pc('-'), n = -n;
if (!n) return (void)pc('0');
int t = n, cnt = 0, rev = 0;
while (!(t%10)) { cnt++; t /= 10;}
do {rev=rev*10 + n%10;} while(n /= 10);
do {pc(rev % 10 + 48);} while(rev /= 10);
while (cnt--) pc('0');
}
int main()
{
int q = 1e7;
while (q--) writeInt(-q);
return 0;
}
#include <iostream>
using namespace std;
inline void writeRec(int n) {
if (n > 9) writeRec(n / 10);
_putchar_nolock(char(n % 10 + '0'));
}
inline void writeInt(int x)
{
if (x < 0) _putchar_nolock('-'), x = -x;
writeRec(x);
}
int main()
{
int q = 1e7;
while (q--) writeInt(-q);
return 0;
}
#include <iostream>
using namespace std;
char os[20];
inline void writeInt(int n)
{
if (n < 0) _putchar_nolock('-'), n = -n;
int i=0;
do os[i++] = n%10; while(n/=10);
while (i--) _putchar_nolock(os[i] + 48);
}
int main()
{
int q = 1e7;
while (q--) writeInt(-q);
return 0;
}
#include <iostream>
using namespace std;
static const int buf_len = (1 << 14);
static const int buf_max = (1 << 04);
static char buf_out[buf_len];
static char buf_num[buf_max];
static int buf_pos = 0;
inline void writeChar(int x) {
if (buf_pos == buf_len) fwrite(buf_out, 1, buf_len, stdout), buf_pos = 0;
buf_out[buf_pos++] = x;
}
inline void writeInt(int x, char end = 0) {
if (x < 0) writeChar('-'), x = -x;
int n = 0;
do buf_num[n++] = x % 10 + '0'; while(x /= 10);
while (n--) writeChar(buf_num[n]);
if (end) writeChar(end);
}
struct Flusher{~Flusher(){if(buf_pos)fwrite(buf_out, 1, buf_pos, stdout),buf_pos=0;}}flusher;
int main()
{
int q = 1e7;
while (q--) writeInt(-q); Flusher();
return 0;
}
#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(true),cin.tie(NULL),cout.tie(NULL);
int q = 1e7;
while (q--) cout << -q;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int q = 1e7;
while (q--) cout << -q;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(NULL),cin.tie(NULL),cout.tie(NULL);
int q = 1e7;
while (q--) cout << -q;
return 0;
}
#include <cstdio>
using namespace std;
int main()
{
int q = 1e7;
while (q--) printf("%d", -q);
return 0;
}
#include <iostream>
using namespace std;
inline void writeInt(int x)
{
if (x < 0) putchar('-'), x = -x;
int p = 1;
for (int t = x / 10; t > 0; t /= 10)
p *= 10;
for (; p > 0; x %= p, p /= 10) putchar(x / p + '0');
}
int main()
{
int q = 1e7;
while (q--) writeInt(-q);
return 0;
}
#include <iostream>
using namespace std;
#define pc putchar
inline void writeInt(int n)
{
if (n < 0) pc('-'), n = -n;
if (!n) return (void)pc('0');
int t = n, cnt = 0, rev = 0;
while (!(t%10)) { cnt++; t /= 10;}
do {rev=rev*10 + n%10;} while(n /= 10);
do {pc(rev % 10 + 48);} while(rev /= 10);
while (cnt--) pc('0');
}
int main()
{
int q = 1e7;
while (q--) writeInt(-q);
return 0;
}
#include <iostream>
using namespace std;
static const int buf_len = (1 << 14);
static const int buf_max = (1 << 04);
static char buf_out[buf_len];
static char buf_num[buf_max];
static int buf_pos = 0;
inline void writeChar(int x) {
if (buf_pos == buf_len) fwrite(buf_out, 1, buf_len, stdout), buf_pos = 0;
buf_out[buf_pos++] = x;
}
inline void writeInt(int x, char end = 0) {
if (x < 0) writeChar('-'), x = -x;
int n = 0;
do buf_num[n++] = x % 10 + '0'; while(x /= 10);
while (n--) writeChar(buf_num[n]);
if (end) writeChar(end);
}
struct Flusher{~Flusher(){if(buf_pos)fwrite(buf_out, 1, buf_pos, stdout),buf_pos=0;}}flusher;
int main()
{
int q = 1e7;
while (q--) writeInt(-q); Flusher();
return 0;
}
#include <iostream>
using namespace std;
char os[20];
inline void writeInt(int n)
{
if (n < 0) putchar('-'), n = -n;
int i=0;
do os[i++] = n%10; while(n/=10);
while (i--) putchar(os[i] + 48);
}
int main()
{
int q = 1e7;
while (q--) writeInt(-q);
return 0;
}
#include <iostream>
using namespace std;
inline void writeRec(int n) {
if (n > 9) writeRec(n / 10);
putchar(char(n % 10 + '0'));
}
inline void writeInt(int x)
{
if (x < 0) putchar('-');
writeRec(abs(x));
}
int main()
{
int q = 1e7;
while (q--) writeInt(-q);
return 0;
}
#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(true),cin.tie(NULL),cout.tie(NULL);
int q = 1e7;
while (q--) cout << -q;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int q = 1e7;
while (q--) cout << -q;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(NULL),cin.tie(NULL),cout.tie(NULL);
int q = 1e7;
while (q--) cout << -q;
return 0;
}
#include <iostream>
using namespace std;
#define pc putchar
inline void writeInt(int n)
{
if (n < 0) pc('-'), n = -n;
if (!n) return (void)pc('0');
int t = n, cnt = 0, rev = 0;
while (!(t%10)) { cnt++; t /= 10;}
do {rev=rev*10 + n%10;} while(n /= 10);
do {pc(rev % 10 + 48);} while(rev /= 10);
while (cnt--) pc('0');
}
int main()
{
int q = 1e7;
while (q--) writeInt(-q);
return 0;
}
#include <iostream>
using namespace std;
inline void writeRec(int n) {
if (n > 9) writeRec(n / 10);
putchar(char(n % 10 + '0'));
}
inline void writeInt(int x)
{
if (x < 0) putchar('-');
writeRec(abs(x));
}
int main()
{
int q = 1e7;
while (q--) writeInt(-q);
return 0;
}
#include <iostream>
using namespace std;
char os[20];
inline void writeInt(int n)
{
if (n < 0) putchar('-'), n = -n;
int i=0;
do os[i++] = n%10; while(n/=10);
while (i--) putchar(os[i] + 48);
}
int main()
{
int q = 1e7;
while (q--) writeInt(-q);
return 0;
}
#include <iostream>
using namespace std;
inline void writeInt(int x)
{
if (x < 0) putchar('-'), x = -x;
int p = 1;
for (int t = x / 10; t > 0; t /= 10)
p *= 10;
for (; p > 0; x %= p, p /= 10) putchar(x / p + '0');
}
int main()
{
int q = 1e7;
while (q--) writeInt(-q);
return 0;
}
#include <cstdio>
using namespace std;
int main()
{
int q = 1e7;
while (q--) printf("%d", -q);
return 0;
}
#include <iostream>
using namespace std;
static const int buf_len = (1 << 14);
static const int buf_max = (1 << 04);
static char buf_out[buf_len];
static char buf_num[buf_max];
static int buf_pos = 0;
inline void writeChar(int x) {
if (buf_pos == buf_len) fwrite(buf_out, 1, buf_len, stdout), buf_pos = 0;
buf_out[buf_pos++] = x;
}
inline void writeInt(int x, char end = 0) {
if (x < 0) writeChar('-'), x = -x;
int n = 0;
do buf_num[n++] = x % 10 + '0'; while(x /= 10);
while (n--) writeChar(buf_num[n]);
if (end) writeChar(end);
}
struct Flusher{~Flusher(){if(buf_pos)fwrite(buf_out, 1, buf_pos, stdout),buf_pos=0;}}flusher;
int main()
{
int q = 1e7;
while (q--) writeInt(-q); Flusher();
return 0;
}
#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(true),cin.tie(NULL),cout.tie(NULL);
int q = 1e7;
while (q--) cout << -q;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(NULL),cin.tie(NULL),cout.tie(NULL);
int q = 1e7;
while (q--) cout << -q;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int q = 1e7;
while (q--) cout << -q;
return 0;
}
#include <iostream>
using namespace std;
#define pc putchar
inline void writeInt(int n)
{
if (n < 0) pc('-'), n = -n;
if (!n) return (void)pc('0');
int t = n, cnt = 0, rev = 0;
while (!(t%10)) { cnt++; t /= 10;}
do {rev=rev*10 + n%10;} while(n /= 10);
do {pc(rev % 10 + 48);} while(rev /= 10);
while (cnt--) pc('0');
}
int main()
{
int q = 1e7;
while (q--) writeInt(-q);
return 0;
}
#include <iostream>
using namespace std;
inline void writeInt(int x)
{
if (x < 0) putchar('-'), x = -x;
int p = 1;
for (int t = x / 10; t > 0; t /= 10)
p *= 10;
for (; p > 0; x %= p, p /= 10) putchar(x / p + '0');
}
int main()
{
int q = 1e7;
while (q--) writeInt(-q);
return 0;
}
#include <iostream>
using namespace std;
inline void writeRec(int n) {
if (n > 9) writeRec(n / 10);
putchar(char(n % 10 + '0'));
}
inline void writeInt(int x)
{
if (x < 0) putchar('-');
writeRec(abs(x));
}
int main()
{
int q = 1e7;
while (q--) writeInt(-q);
return 0;
}
#include <iostream>
using namespace std;
char os[20];
inline void writeInt(int n)
{
if (n < 0) putchar('-'), n = -n;
int i=0;
do os[i++] = n%10; while(n/=10);
while (i--) putchar(os[i] + 48);
}
int main()
{
int q = 1e7;
while (q--) writeInt(-q);
return 0;
}
#include <cstdio>
using namespace std;
int main()
{
int q = 1e7;
while (q--) printf("%d", -q);
return 0;
}
#include <iostream>
using namespace std;
static const int buf_len = (1 << 14);
static const int buf_max = (1 << 04);
static char buf_out[buf_len];
static char buf_num[buf_max];
static int buf_pos = 0;
inline void writeChar(int x) {
if (buf_pos == buf_len) fwrite(buf_out, 1, buf_len, stdout), buf_pos = 0;
buf_out[buf_pos++] = x;
}
inline void writeInt(int x, char end = 0) {
if (x < 0) writeChar('-'), x = -x;
int n = 0;
do buf_num[n++] = x % 10 + '0'; while(x /= 10);
while (n--) writeChar(buf_num[n]);
if (end) writeChar(end);
}
struct Flusher{~Flusher(){if(buf_pos)fwrite(buf_out, 1, buf_pos, stdout),buf_pos=0;}}flusher;
int main()
{
int q = 1e7;
while (q--) writeInt(-q); Flusher();
return 0;
}
Single Line Template
char os[20];
inline void writeInt(int n){if(n<0)putchar('-'),n=-n;int i=0;do{os[i++]=n%10;}while(n/=10);while(i--)putchar(os[i]+48);}
inline void writeInt(int x){if(x<0)putchar('-'),x=-x;int p=1;for(int t=x/10;t>0;t/=10)p*=10;for(;p>0;x%=p,p/=10)putchar(x/p+'0');}
#define pc putchar
inline void writeInt(int n){if(n<0)pc('-'),n=-n;if(!n)return(void)pc('0');int t=n,cnt=0,rev=0;while(!(t%10)){cnt++;t/=10;}do{rev=rev*10+n%10;}while(n/=10);do{pc(rev%10+48);}while(rev/=10);while(cnt--)pc('0');}
inline void writeRec(int n){if(n>9)writeRec(n/10);putchar(char(n%10+'0'));}
inline void writeInt(int x){if(x<0)putchar('-');writeRec(abs(x));}
char os[20];
inline void writeInt(int n){if(n<0)_putchar_nolock('-'),n=-n;int i=0;do{os[i++]=n%10;}while(n/=10);while(i--)_putchar_nolock(os[i]+48);}
inline void writeInt(int x){if(x<0)_putchar_nolock('-'),x=-x;int p=1;for(int t=x/10;t>0;t/=10)p*=10;for(;p>0;x%=p,p/=10)_putchar_nolock(x/p+'0');}
#define pc _putchar_nolock
inline void writeInt(int n){if(n<0)pc('-'),n=-n;if(!n)return(void)pc('0');int t=n,cnt=0,rev=0;while(!(t%10)){cnt++;t/=10;}do{rev=rev*10+n%10;}while(n/=10);do{pc(rev%10+48);}while(rev/=10);while(cnt--)pc('0');}
inline void writeRec(int n){if(n>9)writeRec(n/10);_putchar_nolock(char(n%10+'0'));}
inline void writeInt(int x){if(x<0)_putchar_nolock('-');writeRec(abs(x));}
printf("%d", x);
ios::sync_with_stdio(NULL),cin.tie(NULL),cout.tie(NULL);
ios::sync_with_stdio(true),cin.tie(NULL),cout.tie(NULL);
cout << x;
static const int buf_len = (1 << 14), buf_max = (1 << 04);
static char buf_out[buf_len], buf_num[buf_max];
static int buf_pos = 0;
inline void writeChar(int x){if(buf_pos==buf_len)fwrite(buf_out,1,buf_len,stdout),buf_pos=0;buf_out[buf_pos++]=x;}
inline void writeInt(int x,char end=0){if(x<0)writeChar('-'),x=-x;int n=0;do{buf_num[n++]=x%10+'0';}while(x/=10);while(n--)writeChar(buf_num[n]);if(end)writeChar(end);}
struct Flusher{~Flusher(){if(buf_pos)fwrite(buf_out, 1, buf_pos, stdout),buf_pos=0;}}flusher;
----------
----------
----------
I dont know how to use Template for multiple input. Can you help me ?
template <typename T>
bool read_int(T &x) {
bool start = false , neg = false;
T ret = 0;
for (char r; r = getchar(); ) {
if (r == '-') neg = true;
else if ((r < '0' || r > '9'))
if (start) return false; else continue;
else
ret += r - '0';
if (start) ret *=10;
start = true;
}
return x = (neg ? -ret : ret), true;
}
template <typename T, typename... Tnext>
bool read_int(T &x, Tnext... next)
{
read_int(next...);
}
Sorry for my bad English. Correct me if I am wrong.
Thanks for reading <3
I recently found the opperator co_await
and co_yield
in C++. How should I apply this into the code and should I use these operator in competitive programming ?
Sorry for my bad English and knowledge.
If I am wrong about something please guide me.
Thanks for reading <3
Question: Given two positive numbers N and M, find minimal |c — M| where N mod c = 0
Can we solve this problem in O(log (n))
or faster ?
Here is my approach in O(sqrt(n))
int f(int n, int m)
{
int r = 1;
int rt = sqrt(n);
for (int i = 1; i <= rt; ++i)
{
if (n % i == 0)
{
int j = n / i;
r = abs(r - m) < abs(j - m) ? r : j;
r = abs(r - m) < abs(i - m) ? r : i;
}
}
return r;
}
Sorry for my bad English ;-;
If I have wrong something, please tell me. It is better to do that than just downvote me because I and someone will learn many new things <3
Name |
---|