201912-1
#include<iostream>
using namespace std;
int skip[4];
**bool judge(int n)
{
int t=0;
while(n&&t!=7)
{
t=n%10;
n/=10;
}
if(t==7) return true;
return false;
}**
int main()
{
int n;
cin>>n;
int count=0;
int turn=0;
int i=1;
while(count<n)
{
if(i%7==0||judge(i))
skip[turn]++;
else count++;
turn=(turn+1)%4;
i++;
}
for(int i=1;i<4;i++)
cout<<skip[i]<<endl;
cout<<skip[0]<<endl;
return 0;
}
2019-2(非原创)
#include<iostream>
#include<vector>
using namespace std;
struct Node{
int x,y;
}node;
vector<Node>G,V;
int ans[5];
int main(){
int n;
cin>>n;
for(int i = 0; i < n; i++){
cin>>node.x>>node.y;
G.push_back(node);
}
for(int i = 0; i < n; i++){
int count = 0;
for(int j = 0; j < n; j++){
if((G[i].x == G[j].x&&G[i].y-1 == G[j].y) || (G[i].x == G[j].x&&G[i].y+1 == G[j].y)
|| (G[i].x-1 == G[j].x&&G[i].y == G[j].y) || (G[i].x+1 == G[j].x&&G[i].y == G[j].y)){
count++;
}
if(count == 4) break;
}
if(count == 4){
V.push_back(G[i]);
}
}
for(int i = 0; i < V.size(); i++){
int count = 0;
for(int j = 0; j < G.size(); j++){
if((V[i].x-1 == G[j].x&&V[i].y-1 == G[j].y) || (V[i].x-1 == G[j].x&&V[i].y+1 == G[j].y)
|| (V[i].x+1 == G[j].x&&V[i].y-1 == G[j].y) || (V[i].x+1 == G[j].x&&V[i].y+1 == G[j].y)){
count++;
}
if(count == 4) break;
}
ans[count]++;
}
for(int i = 0; i < 5; i++){
cout<<ans[i]<<endl;
}
return 0;
}
10分代码(运行超时)
#include <iostream>
using namespace std;
#define MAX 1001
int ans[5];
int laji[MAX][MAX];
int main()
{
int n;
cin>>n;
int px,py;
for(int i=0;i<n;i++)
{
cin>>px>>py;
laji[px][py]=1;
}
for(int i=0;i<MAX;i++)
{
for(int j=0;j<MAX;j++)
{
if(laji[i][j]==1)
{
int cn=0;
while(laji[i+1][j]==1&&laji[i][j+1]==1&&laji[i-1][j]==1&&laji[i][j-1]==1)
{
if(laji[i+1][j+1]==1)
cn++;
if(laji[i+1][j-1]==1)
cn++;
if(laji[i-1][j-1]==1)
cn++;
if(laji[i-1][j+1]==1)
cn++;
ans[cn]++;
}
}
}
}
for(int i=0;i<5;i++)
cout<<ans[i]<<endl;
return 0;
}
100分代码:
#include <iostream>
#include<vector>
using namespace std;
#define MAX 1001
int ans[5];
struct A{
int x;
int y;
}a[MAX];
int main()
{
int n;
cin>>n;
int px,py;
for(int i=0;i<n;i++)
{
cin>>px>>py;
a[i].x=px;
a[i].y=py;
}
int flag,cn;
for(int i=0;i<n;i++)
{
flag=cn=0;
for(int j=0;j<n;j++)
{
if(a[j].x==a[i].x&&a[j].y+1==a[i].y)
{
flag++;
}
else if(a[j].x==a[i].x&&a[j].y-1==a[i].y)
{
flag++;
}
else if(a[j].x+1==a[i].x&&a[j].y==a[i].y)
{
flag++;
}
else if(a[j].x-1==a[i].x&&a[j].y==a[i].y)
{
flag++;
}
else if(a[j].x-1==a[i].x&&a[j].y+1==a[i].y)
{
cn++;
}
else if(a[j].x+1==a[i].x&&a[j].y+1==a[i].y)
{
cn++;
}
else if(a[j].x-1==a[i].x&&a[j].y-1==a[i].y)
{
cn++;
}
else if(a[j].x+1==a[i].x&&a[j].y-1==a[i].y)
{
cn++;
}
}
if(flag==4)
{
ans[cn]++;
}
}
for(int i=0;i<5;i++)
cout<<ans[i]<<endl;
return 0;
}