📄 汽车加油问题.cpp
字号:
#include<iostream.h>
#include <fstream.h> // for operation on files
ifstream fin("input.txt");
ofstream fout("output.txt");
void main()
{
int n, k;
int s[1000];
int i,t,l,tag=1;
fin >> n >> k;
for(i=0;i<=k;i++)
fin >> s[i];
l=n;
t=0;
for(i=0;i<=k;i++)
if(s[i]<=n)
if(s[i]>l)
{
l=n-s[i];
t++;
}
else
l=l-s[i];
else
{
cout<<"no solution"<<endl;
fout<<"no solution"<<endl;
tag=0;
break;
}
//
if(tag==1)
fout << t << endl;
cout << t << endl;
//
// close the opened files
fin.close();
fout.close();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -