本文最后更新于 330 天前,其中的信息可能已经有所发展或是发生改变。
题目大意:
思想:
代码:
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define IOS ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define re register
#define fi first
#define se second
#define endl '\n'
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const int INF = 0x3f3f3f3f, mod = 1e9 + 7;
const double eps = 1e-6, PI = acos(-1);
void solve(){
int res = 0;
string s; getline(cin, s);
for(int i = 0; i < s.size(); i ++){
int cnt = 0;
while(s[i] == '6'){
cnt ++;
if(i < s.size()); i ++;
res = max(res, cnt);
}
}
cout << res << endl;
}
int main(){
IOS;
int _ = 1;
// cin >> _;
while(_ --){
solve();
}
return 0;
}
题目大意:
思想:
代码:
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define IOS ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define re register
#define fi first
#define se second
#define endl '\n'
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const int INF = 0x3f3f3f3f, mod = 1e9 + 7;
const double eps = 1e-6, PI = acos(-1);
const int N = 110;
int mp[N][N];
int n, m, q;
bool check(int l, int r){
if(l >= 0 && l < n && r >= 0 && r < m) return 1;
return 0;
}
int dx[] = {-2, -1, -1, -1, 0, 0, 0, 0, 0, 1, 1, 1, 2};
int dy[] = {0, -1, 0, 1, -2, -1, 0, 1, 2, -1, 0, 1, 0};
void st(int l, int r){
for(int i = 0; i < 13; i ++){
int x = l + dx[i], y = r + dy[i];
if(check(x, y)) mp[x][y] = 0;
}
}
void solve(){
cin >> n >> m >> q;
for(re int i = 0; i < n; i ++){
for(re int j = 0; j < m; j ++){
cin >> mp[i][j];
}
}
while(q --){
int l, r;
cin >> l >> r;
st(l, r);
}
int ans = 0;
for(re int i = 0; i < n; i ++){
for(re int j = 0; j < n; j ++){
ans = max(ans, mp[i][j]);
}
}
if(ans == 0) cout << -1 << endl;
else cout << ans << endl;
}
int main(){
IOS;
int _ = 1;
// cin >> _;
while(_ --){
solve();
}
return 0;
}
题目大意:
思想:
代码:
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define IOS ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define re register
#define fi first
#define se second
#define endl '\n'
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const int INF = 0x3f3f3f3f, mod = 1e9 + 7;
const double eps = 1e-6, PI = acos(-1);
const int N = 110;
void solve(){
string s; cin >> s;
for(int i = 0; i < s.size(); i ++){
if(s[i] == '5') cout << 2;
else if(s[i] == '2') cout << 0;
else if(s[i] == '0') cout << 5;
}
return ;
}
int main(){
IOS;
int _ = 1;
// cin >> _;
while(_ --){
solve();
}
return 0;
}
题目大意:
思想:
代码:
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define IOS ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define re register
#define fi first
#define se second
#define endl '\n'
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const int INF = 0x3f3f3f3f, mod = 1e9 + 7;
const double eps = 1e-6, PI = acos(-1);
int n, m;
int sx, sy, ex, ey;
const int N = 100;
char mp[N][N];
bool vis1, vis2;
int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
bool check(int l, int r){
if(l >= 0 && l < n - 1 && r >= 0 && r < n - 1 && mp[l][r] != 'E') return 1;
return 0;
}
void solve(){
cin >> sx >> sy >> ex >> ey;
cin >> n >> m;
for(int i = 0; i < n; i ++){
for(int j = 0; j < n; j ++){
mp[i][j] = '.';
}
}
for(int i = 0; i < m; i ++){
int x, y;
cin >> x >> y;
mp[x][y] = '*';
}
for(int i = 0; i < 4; i ++){
int x = sx + dx[i], y = sy + dy[i];
if(check(x, y)){
if(mp[x][y] == '.'){
vis1 = 1; break;
}
}
}
for(int i = 0; i < 4; i ++){
int x = ex + dx[i], y = ey + dy[i];
if(check(x, y)){
if(mp[x][y] == '.'){
vis2 = 1; break;
}
}
}
if(vis1 && vis2 || (sx == ex && sy == ey)) cout << "Yes!" << endl;
else cout << "No!" << endl;
}
int main(){
IOS;
int _ = 1;
// cin >> _;
while(_ --){
solve();
}
return 0;
}
题目大意:
思想:
代码:
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define IOS ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define re register
#define fi first
#define se second
#define endl '\n'
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const int INF = 0x3f3f3f3f, mod = 1e9 + 7;
const double eps = 1e-6, PI = acos(-1);
const int N = 110;
int n;
double X1, X2, Y1, Y2, cnt = 1e8;
bool check(int l, int r){
double t = 1e8;
if(l >= X1 && l <= X2) t = min(fabs(r - Y1), fabs(r - Y2));
else if(r >= Y1 && r <= Y2) t = min(fabs(l - X1), fabs(l - X2));
double p = min(min(sqrt((l - X1) * (l - X1) + (r - Y2) * (r - Y2)), sqrt((l - X1) * (l - X1) + (r - Y1) * (r - Y1))), min(sqrt((l - X2) * (l - X2) + (r - Y1) * (r - Y1)), sqrt((l - X2) * (l - X2) + (r - Y2) * (r - Y2))));
if(cnt > min(t, p)){
cnt = min(t, p);
return 1;
}
return 0;
}
void solve(){
cin >> n;
cin >> X1 >> Y1 >> X2 >> Y2;
int num = INF;
double res = 1e8;
int flag = 0;
for(int i = 1; i <= n; i ++){
int l, r; cin >> l >> r;
if(check(l, r)){
flag = i; res = cnt;
}
}
cout << flag << endl;
}
int main(){
IOS;
int _ = 1;
// cin >> _;
while(_ --){
solve();
}
return 0;
}
题目大意:
思想:
代码:
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define IOS ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define re register
#define fi first
#define se second
#define endl '\n'
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const int N = 1e5 + 10;
const int INF = 0x3f3f3f3f, mod = 19960515;
const double eps = 1e-6, PI = acos(-1);
int a[N];
void solve(){
LL i, g, j; cin >> i >> g >> j;
LL t = (g - a[i - 1]) / a[i];
if(t <= 0 || (g - a[i - 1]) % a[i]) cout << -1 << endl;
else cout << ((a[j] * t) % mod + a[j - 1] % mod) % mod << endl;
}
int main(){
IOS;
int _ = 1;
a[1] = 1;
for(int i = 2; i <= N; i ++) a[i] = (a[i - 1] + a[i - 2]) % mod;
cin >> _;
while(_ --){
solve();
}
return 0;
}
题目大意:
思想:
-
。代码:
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define IOS ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define re register
#define fi first
#define se second
#define endl '\n'
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const int N = 1e6 + 3;
const int INF = 0x3f3f3f3f, mod = 1e9 + 7;
const double eps = 1e-6, PI = acos(-1);
void solve(){
string s; cin >> s;
int flag = 0;
if(s[0] == '-'){
cout << '-';
for(int i = 1; i < s.size(); i ++){
if(s[i] != '0'){
flag = i;
break;
}
}
if(flag == 0){
cout << 0 << endl;
return ;
}
}
else{
bool vis = 0;
for(int i = 0; i < s.size(); i ++){
if(s[i] != '0'){
flag = i;
vis = 1; break;
}
}
if(!vis){
cout << 0 << endl;
return;
}
}
reverse(s.begin(), s.end());
for(int i = 0; i < s.size() - flag; i ++){
if(i == 0) while(s[i] == '0') i ++;
cout << s[i];
}
}
int main(){
IOS;
int _ = 1;
// cin >> _;
while(_ --){
solve();
}
return 0;
}
题目大意:
思想:
代码:
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define IOS ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define re register
#define fi first
#define se second
#define endl '\n'
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const int N = 1e6 + 3;
const int INF = 0x3f3f3f3f, mod = 1e9 + 7;
const double eps = 1e-6, PI = acos(-1);
void solve(){
int t; cin >> t;
int cnt1 = 0, cnt2 = 0;
while(t --){
string s; cin >> s;
if(s == "我ZY就喜欢这个") cnt1 ++;
if(s == "我ZY实名邀请您于圣源二楼就餐") cnt2 ++;
}
cout << cnt1 << " " << cnt2 << endl;
if(cnt1 + cnt2 > 3) cout << 6 << endl;
}
int main(){
IOS;
int _ = 1;
// cin >> _;
while(_ --){
solve();
}
return 0;
}