/ WOJ / 讨论 / C++ /

一些常用C/C++代码

\(\textcolor{black}{\textup{\textrm{您也可以在评论区添加代码}}}\)

cin/cout \(\textcolor{black}{\textup{\textrm{优化:}}}\) ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);// 加在主函数开头,请勿与scanf/printf混用

\(\textcolor{black}{\textup{\textrm{快读:}}}\)

inline ll read() {
  ll res = 0, f = 1;
  char in = getchar();
  while (in < 48 || in > 57) {
    if (in == '-') {
      f = -f;
    }
    in = getchar();
  }
  while (in > 47 && in < 58) {
    res = (res << 1) + (res << 3) + in ^ 48;
    in = getchar();
  }
  return res;
}

\(\textcolor{black}{\textup{\textrm{快写:}}}\)

inline void write(ll n, char e = '\n', bool ie = 1) {
  if (!n) {
    if (ie) {
      putchar(48);
      putchar(e);
    }
    return;
  }
  write(n / 10, '0', 0);
  putchar((n % 10) ^ 48);
  if (ie) {
    putchar(e);
  }
}

\(\textcolor{black}{\textup{\textrm{主函数:}}}\)

#include <bits/stdc++.h>
// #define endl '\n'
typedef long long ll;
// #define int ll
using namespace std;

signed main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  // Start your code here.
  return 0;
}
    

0 条评论

目前还没有评论...