assmpsit

164

Longlong418
1Wizzy
Acacia_Ma

Eureka_7

hoylindo
SapphireMoonlight
OTTO

#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
int n;
cin >> n;
for (int i = 1; i <= n; i ++ )
{
int a =max(i-1,n-i) ;
printf("%d\n",a * 2 );
}

return 0;
}



#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;
long long  n,m,sum,num;

int main()
{

cin >> n >> m >> num;
int i = 0;

long long a = num / (5 * n + 2 * m);
num = num % (5 * n + 2 * m);
while(num > sum)
{
i++;
if(i < 6) sum += n;
else sum += m;

}
printf("%lld\n",a * 7 + i);

return 0;

}


### 题目描述

1≤n≤100000
1≤q≤10000
1≤k≤10000


6 3
1 2 2 3 3 4
3
4
5


3 4
5 5
-1 -1



y总分析
![

#### C++ 代码


#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

const int N = 100000;
int num[N];
int n,m;

int main()
{

cin>>n>>m;
for (int i = 0; i < n; i ++ ) cin>>num[i];
while (m -- )
{
int x,l = 0,r = n-1,mid = 0;//l 和 r 的更新值不能乱修改，数组从哪到哪就是哪，否则会错
cin >> x;
while(l < r)//寻找左端点
{
mid = (l + r)/ 2;
if(num[mid] >= x)//不能用<=来判断，mid可能会陷入中间而找不到最左边，下边同理
r = mid;
else
l = mid + 1;

}
if(num[r] == x)//判断是否找到这个数，没找到直接退出
{
printf("%d ",l);
r = n - 1;
l = 0;
while(l < r)//寻找右端点
{
mid = (l + r +1)>>1; //mid = (l + r + 1)/2 效果等同
if(num[mid] <= x)
l = mid;//当l = mid的时，mdi的更新值要 +1
else
r = mid-1;
}
printf("%d\n",l);
}
else
{
printf("-1 -1\n");
}
}
return 0;
}


#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

const int N = 100000;
int num[N];
int n,m;

int main()
{

cin>>n>>m;
for (int i = 0; i < n; i ++ ) cin>>num[i];
while (m -- )
{
int x,l = 0,r = n-1,mid = 0;//l 和 r 的更新值不能乱修改，数组从哪到哪就是哪，否则会错
cin >> x;
while(l < r)
{
mid = (l + r)/ 2;
if(num[mid] >= x)
r = mid;
else
l = mid + 1;

}
if(num[r] == x)
{
printf("%d ",l);
r = n - 1;
l = 0;
while(l < r)
{
mid = (l + r +1)>>1;
if(num[mid] <= x)
l = mid;
else
r = mid-1;
}
printf("%d\n",l);
}
else
{
printf("-1 -1\n");
}
}
return 0;
}



#include <iostream>
#include <cstring>
#include <algorithm>
#include <unordered_set>

using namespace std;

int main()
{
int n, m;
scanf("%d", &n);
char str[20];

unordered_set<string> hash;
while (n -- )
{
scanf("%s", str);
hash.insert(str);
}

scanf("%d", &m);
string a, b;

int cnt = 0;
while (m -- )
{
scanf("%s", str);
string name = str;
if (hash.count(name))
{
cnt ++ ;
if (a.empty() || a.substr(6, 8) > name.substr(6, 8)) a = name;
}

if (b.empty() || b.substr(6, 8) > name.substr(6, 8)) b = name;
}

printf("%d\n", cnt);
if (cnt) printf("%s\n", a.c_str());
else printf("%s\n", b.c_str());

return 0;
}



assmpsit
10天前
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

bool is_prime(int m)
{
if (m < 2) return false;
for (int i = 2; i <= m / i; i ++ )
{
if(m % i == 0)
return false;
}
return true;
}
int main()
{
int n,m;
cin >> n;

while(n--)
{
cin >> m;
if(is_prime(m))
printf("Yes\n");
else
printf("No\n");
}

return 0;
}
//for循环里的判断条件可以为i*i<m或i<=sqrt(m)，推荐使用m/i,不会爆表，也没有调用函数
//2也算质数啊，题目有点点问题



assmpsit
10天前
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

bool is_prime(int x)  // 判定质数
{
if(x < 2 ) return false;
for (int i = 2; i <= x / i; i ++ )
{
if (x % i == 0) return false;
}
return true;
}

int main()
{
int n;
cin >> n;
for (int i = n - 6; i <= n+6; i+= 12)//判断是否为性感素数
{
if(is_prime(i) && is_prime(n))
{
cout << "Yes" <<endl;
cout << i ;
return 0;
}

}
for (int i = n + 1 ;; i ++ )//寻找比n大的最小素数
{
if(is_prime(i) && (is_prime(i - 6)|| is_prime(i + 6)))//两者中一个为真即可
{
cout << "No" << endl;
cout << i ;
return 0;
}
}

return 0;
}



assmpsit
29天前
#include<cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

int lowbit(int x)
{
return x & -x;
}

int main()
{
int n;
cin>>n;
while(n--)
{
int x;
cin>>x;

int res =0;
while(x) x -= lowbit(x),res++;//printf("%d ",x);
//printf("\n");
cout<<res<<" ";
}
return 0;
}


assmpsit
1个月前
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
double l=-10000,r=10000,mid,x;
cin>>x;
while(r-l > 1e-10)//控制精度，选择-6的话精度不准，选择-8也行
{
mid=(l+r)/2;
if ( mid*mid*mid < x)
l=mid;//double类型不用考虑+1（（l+r+1）/2）
else
r=mid;
}
printf("%lf",l);//输出l和r都一样
return 0;
}


assmpsit
1个月前
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=1100;
int Sn[N][N];
int num[N][N];
int main()
{
int n,m,q,a;
cin>>n>>m>>q;
for(int i=1;i<=n;i++)
{
//printf("i1=%d\n",i);
for(int j=1;j<=m;j++)
{
scanf("%d ",&num[i][j]);
Sn[i][j]=Sn[i-1][j]+Sn[i][j-1]-Sn[i-1][j-1]+num[i][j];

}
}
int x1,x2,y1,y2;
// printf("数组初始化完成，开始查询\n");
while(q--)
{
scanf("%d %d %d %d ",&x1,&y1,&x2,&y2);
printf("%d\n",Sn[x2][y2] - Sn[x2][y1-1] - Sn[x1-1][y2] + Sn[x1-1][y1-1]);
}

return 0;
}