# 2019高一期中考试 std代码

### T1

``````#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
using namespace std;
#define go(i, j, n, k) for(int i = j; i <= n; i += k)
#define fo(i, j, n, k) for(int i = j; i >= n; i -= k)
#define rep(i, x) for(int i = h[x]; i != -1; i = e[i].nxt)
#define curep(i, x) for(int i = cur[x]; i != -1; i = e[i].nxt)
#define mn 1000100
#define inf 1 << 30
#define ll long long
#define root 1, n, 1
#define lson l, m, rt << 1
#define rson m + 1, r, rt << 1 | 1
#define bson l, r, rt
#define mod 1000000007
int x = 0, f = 1; char ch = getchar();
while(ch > '9' || ch < '0') { if(ch == '-') f = -f; ch = getchar(); }
while(ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
return x * f;
}

ll f[mn], n;

inline void solve() {
f[1] = 1, f[2] = 1, f[3] = 1;
go(i, 4, n, 1)
f[i] = (f[i - 1] + f[i - 3]) % mod;
cout << f[n] << "\n";
}
inline void init() {

}
int main(){
//  while(1) {

init();
solve();
//  }
return 0;
}
``````

### T2

``````#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define go(i, j, n, k) for (int i = j; i <= n; i += k)
#define fo(i, j, n, k) for (int i = j; i >= n; i -= k)
#define rep(i, x) for (int i = h[x]; i; i = e[i].nxt)
#define mn 1000010
#define inf 2147483647
#define ll long long
#define ld long double
#define fi first
#define se second
#define root 1, n, 1
#define lson l, m, rt << 1
#define rson m + 1, r, rt << 1 | 1
#define bson l, r, rt
//#define LOCAL
#define mod
#define Debug(...) fprintf(stderr, __VA_ARGS__)
ll f = 1, x = 0;char ch = getchar();
while (ch > '9' || ch < '0'){if (ch == '-')f = -f;ch = getchar();}
while (ch >= '0' && ch <= '9'){x = x * 10 + ch - '0';ch = getchar();}
return x * f;
}
int n, d[mn];
ll m, a[mn], ans;

int main(){
go(i, 1, n, 1) {
}
go(i, 1, n, 1) {
if(d[i])
ans = max(ans, m + 1 - a[i]);
else
ans = max(ans, a[i]);
}
cout << ans << "\n";
#ifdef LOCAL
Debug("\nMy Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
#endif
return 0;
}``````

P.S. : T2注意 long long

### T3

``````#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
using namespace std;
#define go(i, j, n, k) for(int i = j; i <= n; i += k)
#define fo(i, j, n, k) for(int i = j; i >= n; i -= k)
#define rep(i, x) for(int i = h[x]; i; i = e[i].nxt)
#define mn 101000
#define mm 1010
#define inf 1 << 30
#define ll long long
#define root 1, n, 1
#define lson l, m, rt << 1
#define rson m + 1, r, rt << 1 | 1
#define bson l, r, rt
int x = 0, f = 1; char ch = getchar();
while(ch > '9' || ch < '0') { if(ch == '-') f = -f; ch = getchar(); }
while(ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
return x * f;
}

int a[mn], b[mn], c[mn], n, m; // b鏄€嶆暟锛宑鏄綑鏁?
int hnx[mm][mm];

inline int get_ans(int l, int r, int B, int now) {
//  go(i, l, r, 1)
//      go(j, 0, B, 1)
//          hnx[i][j] = 0;
go(i, l, r, 1) b[i] = a[i];
go(i, l, r, 1) c[i] = b[i] % B;
go(i, l, r, 1) b[i] /= B;
go(i, l, r, 1) {
hnx[c[i]][b[i]] = now;
}
int ans = 0;
go(i, 0, B, 1) {
int j = 0;
while(hnx[i][j] == now) ++j;
ans = max(ans, j);
}
return ans;
}

inline void solve() {
go(i, 1, n, 1) a[i] = read();
go(i, 1, m, 1) {
int ans = get_ans(l, r, B, i);
printf("%d\n", ans);
}
}
inline void init() {

}
int main(){
//  while(1) {

init();
solve();
//  }
return 0;
}
``````

### T4

``````#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
using namespace std;
#define go(i, j, n, k) for(int i = j; i <= n; i += k)
#define fo(i, j, n, k) for(int i = j; i >= n; i -= k)
#define rep(i, x) for(int i = h[x]; i != -1; i = e[i].nxt)
#define curep(i, x) for(int i = cur[x]; i != -1; i = e[i].nxt)
#define mn 1000010
#define inf 1 << 30
#define ll long long
#define root 1, n, 1
#define lson l, m, rt << 1
#define rson m + 1, r, rt << 1 | 1
#define bson l, r, rt
#define mod 19260817
int x = 0, f = 1; char ch = getchar();
while(ch > '9' || ch < '0') { if(ch == '-') f = -f; ch = getchar(); }
while(ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
return x * f;
}

ll ba[mn], f[mn];
int T, n[mn], maxx;

inline void solve() {
go(i, 1, T, 1)
maxx = max(maxx, n[i]);
f[0] = 0, f[1] = 0, f[2] = 1;
go(i, 3, maxx, 1)
f[i] = ((i - 1) * ((f[i - 1] + f[i - 2]) % mod)) % mod;
go(i, 1, T, 1)
printf("%lld\n", f[n[i]]);
}
inline void init() {

}
int main(){
//  while(1) {

init();
solve();
//  }
return 0;
}
``````

2019高一期中考试 std代码

(0)
(0)