Vous êtes sur la page 1sur 2

116

99
64

A three phase delta connected RL load has 10Ω resistance and 31.83mH inductor in
series per phase is fed by a star
connected sinusoidal voltage source of voltage 282.4V (L-L) and 50Hz. Calculate the
(a) load phase voltage and current
(b) load line voltage and current (c) power factor (d) Active and reactive power
per phase (e) three phase apparent power.

#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <queue>
#include <cstdio>
#include <vector>
#include <string>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
#define debug(a) cout << #a << " " << a << endl
using namespace std;
const int maxn = 1e5 + 10;
const int mod = 1e9 + 7;
typedef long long ll;
ll vis[maxn], a[maxn];

int main() {
std::ios::sync_with_stdio(false);
ll n, m;
while( cin >> n >> m ) {
if( !n && !m ) {
break;
}
ll sum = 0, t;
memset( vis, 0, sizeof(vis) );
for( ll i = 1; i <= m; i ++ ) {
cin >> a[i];
}
for( ll i = 1; i <= m; i ++ ) {
sum += a[i];
t = sum%n;
if( t == 0 ) {
for( ll j = 1; j < i; j ++ ) {
cout << j << " ";
}
cout << i << endl;
break;
} else if( vis[t] ) {
for( ll j = vis[t]+1; j < i; j ++ ) {
cout << j << " ";
}
cout << i << endl;
break;
}
vis[t] = i;
}
}
return 0;
}

Problem H: Halloween treats

This problem probably would have been easier given following hint: There always
exists a solution with a selection of consecutive neighbours. The reason why this
is true follows from the fact that c ≤ n, using the pigeonhole principle.

Let us define partial sums Si as the sum of the first i values ai, with S0 = 0.
Then, the sum of the values ai from position i to j can be calculated as Sj - Si-1.
Now, the sum of the values ai from position i to j is divisible by c if and only if
Si-1 = Sj (mod c). Since there are n+1 values Si, but only c ≤ n different
remainders modulo c, according to the pigeonhole principle there must be two
partial sums with the same remainder modulo c.

A linear algorithm solving this problem can be derived as follows: For i = 1 to n,


calculate the partial sum Si as Si-1+ai. Store in a table of size c at position Si
mod c the index i. If there is already an index j stored there, then we know Si and
Sj are equal modulo c and we can construct the solution using the indices j+1 to i.

Vous aimerez peut-être aussi