疑问
查看原帖
疑问
1051310
wang6w6楼主2024/9/29 16:33

为什么我的炒鸡快读全WA了?

样例过了啊。。。

#include<bits/stdc++.h>
using namespace std;
namespace io {
	template <typename T>
	inline void read(T& x) {
		T sum = 0;
		unsigned short ch = getchar();
		for (; !isdigit(ch); ch=getchar());
		for (; isdigit(ch); ch=getchar()) sum = (sum<<1)+(sum<<3) + ch - '0';
		x = sum ;
	}
	template <typename T>
	inline void write(T x) {
		static unsigned short sta[35];
		unsigned short top = 0;
		do {
			sta[top++] = x % 10, x /= 10;
		} while (x);
		while (top) putchar(sta[--top] + 48); 
	}
}
namespace IO
{
  FILE *Fin(stdin), *Fout(stdout);
  class qistream
  {
    static const size_t SIZE = 1 << 16, BLOCK = 32;
    FILE * fp;
    char buf[SIZE];
    int p;

  public:
    qistream(FILE * _fp = stdin) : fp(_fp), p(0)
    {
      fread(buf + p, 1, SIZE - p, fp);
    }

    void flush()
    {
      memmove(buf, buf + p, SIZE - p), fread(buf + SIZE - p, 1, p, fp), p = 0;
    }

    qistream & operator>>(char & str)
    {
      str = getch();
      while (isspace(str))
        str = getch();
      return *this;
    }

    template <class T>
    qistream & operator>>(T & x)
    {
      x = 0;
      p + BLOCK >= SIZE ? flush() : void();
      unsigned short flag = false;
      for (; !isdigit(buf[p]); ++p)
        flag = buf[p] == '-';
      for (; isdigit(buf[p]); ++p)
        x = x * 10 + buf[p] - '0';
      x = flag ? -x : x;
      return *this;
    }

    char getch()
    {
      return buf[p++];
    }

    qistream & operator>>(char * str)
    {
      char ch = getch();
      while (ch <= ' ')
        ch = getch();
      for (unsigned short i = 0; ch > ' '; ++i, ch = getch())
        str[i] = ch;
      return *this;
    }

  } qcin(Fin);

  class qostream
  {
    static const size_t SIZE = 1 << 16, BLOCK = 32;
    FILE * fp;
    char buf[SIZE];
    int p;

  public:
    qostream(FILE * _fp = stdout) : fp(_fp), p(0)
    {}

    ~qostream()
    {
      fwrite(buf, 1, p, fp);
    }

    void flush()
    {
      fwrite(buf, 1, p, fp), p = 0;
    }

    template <class T>
    qostream & operator<<(T x)
    {
      int len = 0;
      p + BLOCK >= SIZE ? flush() : void();
      x < 0 ? (x = -x, buf[p++] = '-') : 0;
      do
        buf[p + len] = x % 10 + '0', x /= 10, ++len;
      while (x);
      for (unsigned short i = 0, j = len - 1; i < j; ++i, --j)
        swap(buf[p + i], buf[p + j]);
      p += len;
      return *this;
    }

    qostream & operator<<(char x)
    {
      putch(x);
      return *this;
    }

    void putch(char ch)
    {
      p + BLOCK >= SIZE ? flush() : void();
      buf[p++] = ch;
    }

    qostream & operator<<(const char * str)
    {
      for (int i = 0; str[i]; ++i)
        putch(str[i]);
      return *this;
    }

  } qcout(Fout);
}
using namespace IO;
#define ll long long
//#define getchar() getchar_unlocked()
//ll rd(){
//	ll f=1,x=0;
//	char c=getchar();
//	while(c<'0'||c>'9'){
//		if(c=='-') f=-1;
//		c=getchar();
//	}
//	while(c>='0'&&c<='9'){
//		x=x*10+c-'0';
//		c=getchar();
//	}
//	return f*x;
//}
ll n,ans,x;
int main() {
//	ios::sync_with_stdio(false);
//	cin.tie(0);
//	cout.tie(0);
//	n=rd();
	cin>>n;
	for(ll i=1;i<=n;i++){
		cin>>x;
		ans+=x;
//		ans+=rd();
	}
	cout<<ans;
	return 0;
}
2024/9/29 16:33
加载中...