A. Ehab and another construction problem
题目:
传送门A
按照题目的要求,只需要将输入的x打印两遍就可以了。
注意还有x=1的情况,这样只需要打印-1即可。
代码如下:
#include
#include
#include
#include
using namespace std;
int main()
{
int x;
scanf("%d",&x);
if(x==1)
{
printf("-1\n");
}
else
{
printf("%d %d\n",x,x);
}
return 0;
}
B. Ehab and subtraction
题目:
传送门B
此题模拟即可。
可以发现,一个数只需要减去前一个数就是要处理的结果。
代码如下:
#include
#include
#include
#include
using namespace std;
const int maxn=1e5+5;
int a[maxn];
int n,k;
int main()
{
scanf("%d%d",&n,&k);
for (int i=0;i=n)
{
i++;
printf("0\n");
}
}
return 0;
}
C. Ehab and a 2-operation task
题目:
传送门C
此题模拟即可,从后往前调到想要的数即可。
代码如下:
#include
#include
#include
#include
#include
using namespace std;
const int maxn=2005;
typedef long long ll;
int n;
ll a[maxn];
ll sum=0;
vectorans,ans2;
int main()
{
scanf("%d",&n);
for (int i=0;i=0;i--,j--)
{
if((a[i]+sum)%stand!=j)
{
ll t=(a[i]+sum)%stand;
ll yu=(t/stand+1)*stand+j-t;
ans.push_back(yu);
ans2.push_back(i+1);
sum+=yu;
}
}
printf("%d\n",ans.size()+1);
for (int i=0;i