超出堆区,如何实现输入超过80,000,000的字符串

问题遇到的现象和发生背景

有多组输入,每组输入占一行
每行一串二进制数,长度 不少于 80,000,000。
如果对应的十进制数可以被3整除则输出yes,否则输出no;

问题相关代码,请勿粘贴截图

#include
#include
int count(char, int, int);//逐位取余函数
using namespace std;
int main()
{
char a[20000];
while (cin >> a)
{
int n = 0, s = 0, i = 0; n = strlen(a);
// cout<
for (i = 0; i < n; i++)
s += count(a[i], i, n - 1);
if (s % 3 == 0)
cout << "yes" << endl;
else
cout << "no" << endl;

}
return 0;

}
int count(char a, int i, int n)
{
int b = 'a' - '0', s = 1;
if (b == 0)
return 0;
else
for (i; i < n; i++)
s *= 2;
return s;
}

运行结果及报错内容

runtime error(非法内存访问,分段错误)

我的解答思路和尝试过的方法

二维数组也没成功;

我想要达到的结果

如何实现输入超过80,000,000的字符串

8千万,差不多80M字节,你动态分配空间
问题是最少80M,那最多呢?1000T?
你用cin输入,那不得输入几辈子?

修改如下,供参考:

#include <iostream>
#include <string>
using namespace std;
char a[80000000];
int count(char, int, int);//逐位取余函数
int main()
{
    
    while (cin >> a)
    {
        int n = 0, s = 0, i = 0; 
        n = strlen(a);
        // cout<<n<<endl;
        for (i = 0; i < n; i++)
            s += count(a[i], i, n - 1);
        if (s % 3 == 0)
            cout << "yes" << endl;
        else
            cout << "no" << endl;
    }
    return 0;
}
int count(char a, int i, int n)
{
    int b = a - '0', s = 1; //int b = 'a' - '0',
    if (b == 0)  //或者这里直接:if(a == '0')
        return 0;
    else
        for (i; i < n; i++)
            s *= 2;
    return s;
}