120812024-12-01 16:56:15ruffbrigiZenehallgatásgolangCompilation error
#include <iostream>

using namespace std;

int main()
{
    long long n,k,s=0;
    cin>>n;
    cin>>k;
    int t[n],p[k];
    for(int i=0;i<=n-1;i++)
    {
        cin>>t[i];
        s=s+t[i];
    }
    for(int j=0;j<=k-1;j++)
    {
        cin>>p[j];
        p[j]=p[j]%s;
    }
    for(int j=0;j<=k-1;j++)
    {
        if(p[j]==0) cout<<n<<" ";
        else
        {
            int i=0;
            int h=t[0];
            while(h<p[j])
            {
                i++;
                h=h+t[i];
            }
           cout<<i+1<<" ";
        }
    }
    return 0;
}
Compilation error
open /var/local/lib/isolate/429/box/a.out: no such file or directory
main.go:1:1: error: invalid character 0x23 in input file
    1 | #include <iostream>
      | ^
main.go:3:1: error: program must start with package clause
    3 | using namespace std;
      | ^
main.go:3:1: error: expected ';' or newline after package clause
main.go:3:1: error: expected declaration
main.go:5:1: error: expected declaration
    5 | int main()
      | ^
main.go:6:1: error: expected declaration
    6 | {
      | ^
main.go:8:5: error: expected declaration
    8 |     cin>>n;
      |     ^
main.go:9:5: error: expected declaration
    9 |     cin>>k;
      |     ^
main.go:10:5: error: expected declaration
   10 |     int t[n],p[k];
      |     ^
main.go:11:5: error: expected declaration
   11 |     for(int i=0;i<=n-1;i++)
      |     ^
main.go:11:17: error: expected declaration
   11 |     for(int i=0;i<=n-1;i++)
      |                 ^
main.go:11:24: error: expected declaration
   11 |     for(int i=0;i<=n-1;i++)
      |                        ^
main.go:12:5: error: expected declaration
   12 |     {
      |     ^
main.go:14:9: error: expected declaration
   14 |         s=s+t[i];
      |         ^
main.go:15:5: error: expected declaration
   15 |     }
      |     ^
main.go:16:5: error: expected declaration
   16 |     for(int j=0;j<=k-1;j++)
      |     ^
main.go:16:17: error: expected declaration
   16 |     for(int j=0;j<=k-1;j++)
      |                 ^
main.go:16:24: error: expected declaration
   16 |     for(int j=0;j<=k-1;j++)
      |                        ^
main.go:17:5: error: expected declaration
   17 |     {
      |     ^
main.go:19:9: error: expected declaration
   19 |         p[j]=p[j]%s;
      |         ^
main.go:20:5: error: expected declaration
   20 |     }
      |     ^
main.go:21:5: error: expected declaration
   21 |     for(int j=0;j<=k-1;j++)
      |     ^
main.go:21:17: error: expected declaration
   21 |     for(int j=0;j<=k-1;j++)
      |                 ^
main.go:21:24: error: expected declaration
  ...